新版nginx配置SSL證書(騰訊雲)
阿新 • • 發佈:2019-01-11
最重要的是記得在安全組開啟443埠
申請證書之後首先將域名 www.domain.com 的
證書檔案:1_www.domain.com_bundle.crt 、
私鑰檔案:2_www.domain.com.key儲存到同一個目錄,例如/etc/nginx/目錄下。
更新/etc/nginx/sites-available目錄下檔案default
如下:
listen 443;
server_name www.domain.com; #填寫繫結證書的域名
ssl on;
ssl_certificate /etc/nginx/1_www.domain .com_bundle.crt;
ssl_certificate_key /etc/nginx/2_www.domain.com.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 / {
root /var/www/html; #站點目錄
index index.html index.htm;
}
將這段配置插入文字中,如圖下位置
然後在80埠設定http跳轉到https
在80埠location中加入rewrite ^(.*)$ https://$host$1 permanent;
如圖,然後輸入命令service nginx reload
重啟伺服器。