隨著大家對網站安全的重視,還有微信小程序開發的原因,大家都越來越重視網站SSL了…
隨著大家對網站安全的重視,還有微信小程序開發的原因,大家都越來越重視網站SSL了。小編今天就給大家分享一下配置SSL的流程,并把非https跳轉到https域名上。
1. 申請SSL證書,本文用的是阿里云的免費SSL證書,申請地址:https://common-buy.aliyun.com/?spm=5176.7968328.1266638..73dc1232tTWHHp&commodityCode=cas#/buy
2. 申請通過后,下載Nginx版本的證書文件,并上傳到服務器。
3. 新增加配置.conf文件
server { listen 443; server_name www.boncent.com; ssl on; root /www/web/boncent/public_html; ssl_certificate /www/nginx/cert/1451280_www.boncent.com.pem; ssl_certificate_key /www/nginx/cert/1451280_www.boncent.com.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; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fcgi.conf; } location / { root /www/web/boncent/public_html; index index.php index.html; } }
4. 重啟Nginx,這步可以安排到第6步操作。
5. 編輯非https的配置文件,增加:
if ($host = "www.boncent.com") { rewrite ^/(.*)$ https://www.boncent.com/$1 permanent; }
讓非https域名強制跳轉到https域名上。
6. 重啟Nginx。