国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

Nginx實現(xiàn)http自動跳轉(zhuǎn)到https

瀏覽:163日期:2023-03-13 15:37:43

https是更安全的http,通過http自動跳轉(zhuǎn)https,可以更便于用戶使用web。

有幾下幾個方法可以完成跳轉(zhuǎn):

1.打開http和https的server,讓http跳轉(zhuǎn)到https

server {
? ? listen 80;
? ? listen [::]:80;
? ? return 301 https://$host$request_uri;
}

server {
? ? listen 443 ssl;
? ? listen [::]:443 ssl;

? ? ssl_certificate ? ? ? ? certificate_file_path;
? ? ssl_certificate_key ?certificate_key_file_path;

? ? ...

}

2.不打開http的server,直接在https的server里完成跳轉(zhuǎn),以下三種方式都可以

server {

? ? if ($server_port = 80 ) ??

? ? #if ($scheme = http )

? ? #if ($ssl_protocol = "")

? ? {
? ? ? ? return 301 https://$host$request_uri;
? ? }

? ??
? ? listen 443 ssl;
? ? listen [::]:443 ssl;

? ? ssl_certificate ? ? ? ? certificate_file_path;
? ? ssl_certificate_key ?certificate_key_file_path;

? ? ...

}

到此這篇關(guān)于Nginx實現(xiàn)http自動跳轉(zhuǎn)到https的文章就介紹到這了,更多相關(guān)Nginx http自動跳轉(zhuǎn)到https內(nèi)容請搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!

標簽: Nginx
主站蜘蛛池模板: 南城县| 蒲城县| 安塞县| 保德县| 宜州市| 宜春市| 广饶县| 古浪县| 金阳县| 康马县| 建德市| 军事| 屏南县| 卓资县| 镇远县| 交口县| 日喀则市| 黄龙县| 如皋市| 安顺市| 新河县| 霞浦县| 洪泽县| 白城市| 高青县| 疏勒县| 石嘴山市| 莎车县| 工布江达县| 张掖市| 黄冈市| 东乌珠穆沁旗| 资溪县| 武定县| 临澧县| 昌都县| 齐齐哈尔市| 阿合奇县| 汾阳市| 湖南省| 邓州市|