要配置ssl證書,首先要買一下ssl證書,能夠在多個平臺上購買,阿里雲,騰訊雲等,還有一些專門賣ssl證書的網站,今天在這裏給你們介紹的是一個免費證書的網站。php
FreeSSL.org 是一個提供免費HTTPS證書申請的網站,而後在首頁的輸入框內輸入你的網站的一級域名而後回車,如今默認是 亞洲誠信的ssl證書無償使用1年,而後輸入郵箱,以後須要域名作一下TXT解析(這個是爲了校驗一下你是否是域名擁有者)css
server {
listen 80;
server_name baidu.com www.baidu.com;
index index.html index.htm index.php;
root /alidata/www/wewe/public;
location / {
index index.php index.html index.htm;
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)$ /index.php last;
}
#引用PHP CGI
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
}
複製代碼
listen 443 ssl;#這個443端口和80端口能夠同時監聽,同時監聽就是http和https均可用,只監聽443就是強制https
server_name wewe.weinvestment.cn;
index index.html index.htm index.php;
root /alidata/www/wewe/public;
#SSL-START SSL相關配置,請勿刪除或修改下一行帶註釋的404規則
#error_page 404/404.html;
ssl_certificate /alidata/server/cert2/full_chain.pem;#這個地方就是剛纔證書上傳的路徑
ssl_certificate_key /alidata/server/cert2/private.key;#這個地方就是剛纔證書上傳的路徑
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
#SSL-END
複製代碼
server {
listen 80;
listen 443 ssl;
server_name baidu.com www.baidu.com;
index index.html index.htm index.php;
root /alidata/www/wewe/public;
#SSL-START SSL相關配置,請勿刪除或修改下一行帶註釋的404規則
#error_page 404/404.html;
ssl_certificate /alidata/server/cert2/full_chain.pem;
ssl_certificate_key /alidata/server/cert2/private.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
#SSL-END
location / {
index index.php index.html index.htm;
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)$ /index.php last;
}
#引用PHP CGI
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
}
複製代碼
nginx -t
html
service nginx restart
nginx