server { listen 443 ssl; server_name www.xxx域名.com; root html; index index.html index.html; ssl_certificate cert/4774584_www.xxx域名.com.pem; ssl_certificate_key cert/4774584_www.xxx域名.com.key; # ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; 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 / { root html; index index.html index.htm; } location /baidu { proxy_pass http://www.baidu.com/; } }
如果需要將nginx反向代理的網址也可以使用htts訪問,那麼需要在443server中新增location /反向代理地址
如果需要http自動https,則應該在80server中新增: rewrite ^(.*)$ https://$host$1 permanent;
server { listen 80; server_name localhost; rewrite ^(.*)$ https://$host$1 permanent; #將所有HTTP請求通過rewrite重定向到HTTPS。 #charset koi8-r; #access_log logs/host.access.log main; # location / { # root html; # index index.html index.htm; # } }
阿里雲新使用者一折大獎+優惠 連結:https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=3ls0qk0b&utm_source=3ls0qk0b