1. 程式人生 > >Nginx服務器http重定向到https

Nginx服務器http重定向到https

nginx http重定向https

Nginx服務器http重定向到https

server {
listen 80;
server_name test-ftqc.navinfo.com;
rewrite ^(.*)$ https://$server_name$1 permanent;
}

或者

server {
listen 80;
server_name test-ftqc.navinfo.com;
rewrite ^ https://$server_name$request_uri? permanent;

}

現在nginx新版本已經換了種寫法,上面這些已經不再推薦。

下面是nginx http頁面重定向到https頁面最新支持的寫法:

復制代碼
server {
listen 80;
server_name test-ftqc.navinfo.com;
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
server_name test-ftqc.navinfo.com;

[....]

}

Nginx服務器http重定向到https