我有一個以下 nginx 組態檔,我想將所有 http 重定向到 https,但使用不同server_name的自定義埠
server {
listen 80;
server_name *.abc.example.com abc.example.com abc.example.local:123;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name *.abc.example.com abc.example.com abc.example.local:456;
}
這有點不同,因為 http 上其他server_name===>的非自定義埠abc.example.local:123需要重定向到abc.example.local:456https
處理這種特殊情況的最佳方法是什么,以便它正確地將所有 http 重定向到 https,而不管 server_name 以及它是否具有不同的 http 和 https 埠
uj5u.com熱心網友回復:
server_name不能有埠 - 只能listen指定一個埠。
如果您想abc.example.local在埠 123 上偵聽 - 您將需要一個單獨的服務器塊。然后另一個服務器塊將偵聽埠 456。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/485047.html
