[II] a rear end note: Nginx installed SSL module configured Https

Download Nginx Source:

http://nginx.org/en/download.html

Extract the source, and enter the folder:

# 下载
wget http://nginx.org/download/nginx-1.17.5.tar.gz
# 解压
tar -zxvf nginx-1.17.5.tar.gz
# 进入目录
cd nginx-1.17.5

SSL module configuration increases:

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

Compile:

make

installation:

sudo make install

After installation is complete, you can find the configuration file in the "/usr/local/nginx/conf/nginx.conf". Modify the configuration file server section as follows:

    # http跳转到https
    server {
        listen       80;
        server_name  www.tfwcn.wang;
        rewrite ^(.*)$ https://$host$1 permanent;    
    }

    server {
       # listen       80;    # 可以与http兼容
       listen       443 ssl;
       server_name  www.xxx.com;    # 域名

       ssl_certificate      cert.pem;    # 证书,绝对路径
       ssl_certificate_key  cert.key;    # 证书,绝对路径

       ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
       ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;
       ssl_prefer_server_ciphers on;
       ssl_session_cache shared:SSL:10m;
       ssl_session_timeout 10m;

       location / {
           root   html;    # 网站绝对路径
           index  index.html index.htm;
       }
    }

Start Nginx:

# 启动Nginx
nginx

# 停止Nginx
nginx -s stop

# 重新加载配置
nginx -s reload

 

Published 28 original articles · won praise 2 · views 10000 +

Guess you like

Origin blog.csdn.net/highlevels/article/details/102879769