nginx在Window平台http自动跳转https设置方法

window平台nginx设置方法(nginx_1.20.1测试通过)

 #此处监听80端口并转向443端口访问网站,可以使用非443端口,在$server_name:端口$中添加对应的端口即可,
     server {
         listen 80;
         server_name 此处填写域名信息;
         return 301 https://$server_name$request_uri;

          location /time {
          root html;
          index index.html index.htm;
          }

      }

# 此处设置443端口访问,证书文件(可使用云平台申请的免费证书)默认在nginx目录中的conf文件夹下,填写以下的加密套件与协议即可

     server {
     listen 443 ssl;
     server_name 此处填写域名信息;

     ssl_certificate 证书文件.pem;
     ssl_certificate_key 证书文件.key;

     ssl_session_cache shared:SSL:1m;
     ssl_session_timeout 5m;
     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件
     ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
     ssl_prefer_server_ciphers on;

        location /time {
        root html;
       index index.html index.htm;
       }
   }

原文地址:https://www.cnblogs.com/52by/p/14901336.html