Nginx實(shí)現(xiàn)https網(wǎng)站配置代碼實(shí)例
https基礎(chǔ) 443端口. 用于了一個叫密鑰的東西. 不要覺得這些東西您不了解也能實(shí)現(xiàn). 不可能的.
1.先成密鑰.咱們直接linux下生成 假設(shè)nginx目錄為 /usr/local/nginx-1.2.9
接下來
cd /usr/local/nginx-1.2.9/conf/;
mkdir ssl;
cd ssl;
#下面開始創(chuàng)建密鑰.如果不熟悉完全不必理會為什么這么做照做就可以了
openssl genrsa -des3 -out server.key 1024;#這一步會讓您輸入密碼. 輸入就可以了 下面這步要用到這個密碼. 隨意
openssl req -new -key server.key -out server.csr;#輸入剛才設(shè)置的密碼后一路回車
cp server.key server.key.org;
openssl rsa -in server.key.org -out server.key;#這一步還需要密碼的
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt;
#到此生成結(jié)束 此時 ssl目錄里有一下幾個文件 server.crt server.csr server.key server.key.org
2.第二步,咱們建一個站點(diǎn). 配置文件如下. (如果不會寫配置文件的朋友可以參考本論壇)
server { listen 443; ssl on; #注意路徑和文件擴(kuò)展名 ssl_certificate /usr/local/nginx-1.2.9/conf/ssl/server.crt; ssl_certificate_key /usr/local/nginx-1.2.9/conf/ssl/server.key; server_name 域名; root 網(wǎng)站根目錄; location / { index index.html index.php; } #支持PHP location ~ \.php{ include fastcgi_params; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; } }
好了 nginx -s reload 重啟nginx看一下吧. 可以使用https訪問了
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持本站。
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。