Nginx 安装配置证书,设置HTTPS站点

详细配置如下:

server {
    listen 80;
    server_name shwww.net www.shwww.net;
    return 301 https://www.shwww.net$request_uri;
}

server {
    charset utf-8;
    listen 443 ssl;
    server_name www.shwww.net; 
    
    ssl on;
    ssl_certificate 1_www.shwww.net_bundle.crt;
    ssl_certificate_key 2_www.shwww.net.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://unix:/www/sockets/www.shwww.net.socket;
    }
}

其中第一部分配置项:

server {
    listen 80;
    server_name shwww.net www.shwww.net;
    return 301 https://www.shwww.net$request_uri;
}

此部分完成了将不含www的域名及含www的域名的80端口直接全部301重定向到含www的https地址,
即将 http://shwww.net/http://www.shwww.net/ 均重定向到 https://www.shwww.net/

如需配置IIS或者Apache的HTTPS站点,可以参考:https://cloud.tencent.com/document/product/400/4143

posted @ 2019-02-19 22:27  隔壁老王python  阅读(191)  评论(0编辑  收藏