我正在嘗試配置 Pound 代理設定檔以將所有請求透過 http 重定向到網站https://www.example.com。我還需要請求https://example.com被重定向到https://www.example.com。
到目前為止我有以下程式碼並且它有效:
ListenHTTP
Address xx.xx.xx.xx
Port 80
Service
HeadRequire "Host:.*example.com.*"
Redirect "https://www.example.com"
End
End
Service
BackEnd
Address xx.xx.xx.xx
Port 8888
End
End
ListenHTTPS
Cert "/home/path/to/subdomain/ssl.everything"
Cert "/home/example/ssl.everything"
Address xx.xx.xx.xx
Port 443
HeadRemove "X-Forwarded-Proto"
AddHeader "X-Forwarded-Proto: https"
Ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384..."
Service
URL "^(/|.*)$"
Redirect "https://www.example.com"
End
End
但是,我不知道如何在 ListenHTTP 中製定規則:
Service
HeadRequire "Host:.*example.com.*"
Redirect "https://www.example.com"
End
尊重同一域的其他子域。目前不幸的是所有子域也被重新導向到https://www.example.com。
ListenHTTPS 部分的規則也存在著同樣的問題。它將所有請求重定向到https://www.example.com:
Service
URL "^(/|.*)$"
Redirect "https://www.example.com"
End
而我只需要https://example.com被重定向到https://www.example.com。
機器人 ListenHTTP 和 ListenHTTPS 阻止的正確模式應該是什麼,以排除同一 IP 上的所有其他域和子域?
答案1
請記住:將應用第一條要應用的規則!基本上,您應該在規則清單的最後建立一個通配符規則。