Nginx配置https

  • 安裝Nginx
  • 修改nginx.conf配置文件
 1 upstream tomcat {
 2         server 127.0.0.1:8083 fail_timeout=0; #後端服務地址
 3     }
 4     server {
 5         listen                  443;
 6         ssl                     on;
 7         server_name             gdufe888.com; #申請證書的域名
 8      // 證書
 9         ssl_certificate         b.pem;  
10         ssl_certificate_key     a.key;  
11         ssl_session_timeout  5m;
12      // 加密算法
13         ssl_protocols TLSv1 TLSv1.1 TLSv1.2 SSLv2 SSLv3;
14         ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
15         ssl_prefer_server_ciphers   on;
16 
17         location / {
18                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19                 proxy_set_header Host $http_host;
20                 proxy_set_header X-Forwarded-Proto https;
21                 proxy_redirect off;
22                 proxy_connect_timeout      240;
23                 proxy_send_timeout         240;
24                 proxy_read_timeout         240;
25                 proxy_pass http://tomcat;
26         }
27     }
28     server {
29         listen                  80;
30         server_name             gdufe888.com;  #http訪問入口
31         location / {
32             rewrite ^ https://$http_host$request_uri? permanent;  #強制跳轉到HTTPS上
33         }
34     }

 

結果以下:nginx

 

 

參考博文:https://blog.csdn.net/benchem/article/details/79605598算法

相關文章
相關標籤/搜索