Nginx 配置https

1、准备好网站域名的https证书,后缀名如下,上传到服务器上。

    xxx.pem   xxx.key     

2、配置nginx.conf

server {
        listen 443 ssl;
        server_name scm.xxx.com;
        ssl on;
       ssl_certificate   ./cert/cert.pem;#证书pem位置
        ssl_certificate_key  ./cert/cert.key;#证书key的路径
        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;
      #禁止访问WEB-INF目录
       location ^~ /(WEB-INF)/ {
          deny all;
      }
    #配置代理路径
      location / {
                proxy_pass http://127.0.0.1:8080/scm/;
              proxy_cookie_path  /scm/  /;
          }  #静态资源访问
    location ~ \.(txt) {
                root   /usr/local/tomcat9/webapps/scm;
                autoindex on;          
    }
       }
}

  3、重载nginx服务器
  到 nginx/sbin 目录下执行如下命令即可
    

./nginx -s reload

相关推荐