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;
[....]
}
时间: 2024-10-10 04:31:16