最近在升級交流學習社區,以爲有必要升級成https.如下是本身在升級中記錄。html
如下包括如下部分:node
1、阿里雲免費購買SSL證書nginx
一、本身在阿里雲申請了免費的,而後本身支付0元,購買了SSL證書git
二、我選擇DNS驗證github
三、在SSL證書中,下載cert證書,而後放到nginx服務器上服務器
2、nginx無縫升級httpssession
四、查看nginx是否支持ssl學習
五、配置ssl模塊網站
六、從新編譯一下ui
七、由於此次是升級nginx,因此不須要執行 make install,首先備份原nginx執行腳本
八、把新編譯的nginx執行腳本拷貝到相應的目錄下:’
九、最後進行平滑升級
十、再次檢查nginx是否有https模塊
十一、展現一下https網站站點,https://www.mwcxs.top/
附註1:nginx配置SSL報錯問題,ssl on報錯
附註2:nginx的https服務配置
一、本身在阿里雲申請了免費的,而後本身支付0元,購買了SSL證書
二、我選擇DNS驗證,由於域名是本身的。
DNS驗證方式通常須要由您的域名管理人員進行相關操做。請按照您的證書訂單中的進度提示,在您的域名管理系統中進行相應配置。
三、在SSL證書中,下載cert證書,而後放到nginx服務器上
四、查看nginx是否支持ssl:
./nginx -V
查看 configure arguments 信息中是否包含 -with-http_ssl_module 字樣
五、配置ssl模塊
找到以前安裝 Nginx 時的解壓目錄,配置ssl模塊:
./configure --with-http_ssl_module
六、從新編譯一下
在解壓目錄執行make
make
七、由於此次是升級nginx,因此不須要執行 make install,首先備份原nginx執行腳本:
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
八、把新編譯的nginx執行腳本拷貝到相應的目錄下:
cd objs
cp nginx /usr/local/nginx/sbin/
九、最後進行平滑升級
cd ..
make upgrade
十、再次檢查nginx是否有https模塊
十一、展現一下https網站站點,https://www.mwcxs.top/
附註1:nginx配置SSL報錯問題,ssl on報錯
啓動報錯(錯誤信息:nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /home/soft/nginx/conf/nginx.conf:76)
須要配置模塊ssl模塊 --with-http_ssl_modul,請查看本文的第二部分:二、配置ssl模塊
附註2:nginx的https服務配置
# HTTPS server server { listen 443; server_name www.mwcxs.top; ssl on; root /home/nodejs/liblog/www; index index.js index.html index.htm; ssl_certificate /usr/local/nginx/cert/15420110408020120565539868.crt; ssl_certificate_key /usr/local/nginx/cert/15420110408020120565539868.key; ssl_session_cache shared:SSL:1m; 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; if ( -f $request_filename/index.html ){ rewrite (.*) $1/index.html break; } if ( !-f $request_filename ){ rewrite (.*) /index.js; } location / { proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_pass http://learning_community_node$request_uri; proxy_redirect off; } location = /production.js { deny all; } location = /testing.js { deny all; } location ~ /static/ { etag on; expires max; } }
server { listen 80; server_name www.mwcxs.top mwcxs.top; return 301 https://$server_name$request_uri; }
注:return 301 https://$server_name$request_uri;用來把http轉換成https。
歡迎關注:https://github.com/saucxs/nodeJSBlog ,歡迎fork和start