一、nginx如何啟動
1、HTTP和HTTPS的區別
https協議需要到ca申請證書,一般免費證書很少,需要交費。
http是超文本傳輸協議,信息是明文傳輸,https 則是具有安全性的ssl加密傳輸協議。
http和https使用的是完全不同的連接方式,用的端口也不一樣,前者是80,后者是443。
http的連接很簡單,是無狀態的;HTTPS協議是由SSL+HTTP協議構建的可進行加密傳輸、身份認證的網絡協議,比http協議安全。
所以在涉及到賬戶、金錢等敏感信息交互的時候使用HTTPS是個不錯的選擇。
2、申請證書
申請SSL證書過程就不多說了。挺簡單的,本文主要是在nginx上配置ssl證書實現https訪問。
將key和證書上傳到服務器。
3、nginx配置
代碼如下
server {listen 443;#listen [::]:80;server_name passport.ddhigh.com;index index.html index.htm index.php default.html default.htm default.php;root /home/wwwroot/passport.ddhigh.com;include other.conf;#error_page 404 /404.html;location ~ [^/]/.php(/|$){# comment try_files $uri =404; to enable pathinfotry_files $uri =404;fastcgi_pass unix:/tmp/php-cgi.sock;fastcgi_index index.php;include fastcgi.conf;#include pathinfo.conf;}location ~ .*/.(gif|jpg|jpeg|png|bmp|swf)${expires 30d;}location ~ .*/.(js|css)?${expires 12h;}ssl on;ssl_certificate /root/crt/server.crt;ssl_certificate_key /root/crt/server.key;access_log /home/wwwlogs/passport.ddhigh.com.log access;}
/root/crt是我的證書目錄,各位讀者可以根據實際情況更改。
二、nginx ssl 免密碼重啟
設置ssl之后每次重啟nginx都需要手動輸入證書密碼,非常麻煩,一旦輸出就要重來。
利用openssl可以將有密碼的私鑰轉化為免密碼的私鑰。
openssl rsa -in server.key -out server.key.nopassword
nginx配置ssl的時候將server.key的路徑配置為server.key.nopassword的路徑即可。
以上所述是小編給大家介紹的nginx ssl免密碼重啟教程詳解,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對錯新站長站網站的支持!
新聞熱點