我遇到一个问题,即 wildcard.domain.com 无法 100% 正常工作。转到 https://wildcard.domain.com 时似乎失败了,其中 https://www.wildcard.domain.com作品。所以我有以下磅配置:
##
# 1 http://*.test.domain.com
##
ListenHTTP
Address 10.xx.xx.xx
Port 80
HeadRemove "X-HTTPS-via-LB"
RewriteLocation 0
xHTTP 0
Service "test domain"
HeadRequire "^Host:.*test\.domain\.com\s*$"
Redirect "https://www.test.domain.com"
End
End
##
# 2 https://*.test.domain.com
##
ListenHTTPS
Address 10.xx.xx.xx
RewriteLocation 0
HeadRemove "X-HTTPS-via-LB"
AddHeader "X-HTTPS-via-LB: 1"
Port 443
xHTTP 0
Cert "/etc/pki/tls/private/wildcard.test.domain.com.combined"
Ciphers "****"
End
现在这几乎可以工作了,但在某些情况下仍然会失败:
WORKS:用户转到 http://test.domain.com , Pound 向用户呈现 https://www.test.domain.com/
WORKS:用户转到 http://www.test.domain.com , Pound 向用户呈现 https://www.test.domain.com/
WORKS:用户转到 https://www.test.domain.com , Pound 向用户呈现 https://www.test.domain.com/
失败:用户转到https://test.domain.com/ , Pound 向用户显示“您的连接不是私有(private)的”
我不明白如何解决这个问题,是否只需要向 HTTPS 监听器添加一个正则表达式?
最佳答案
如果您的证书仅指示 *.test.domain.com 对 test.domain.com 无效,则仅适用于子域(且仅适用于一级)。
那一行有一个错误:
HeadRequire "^Host:.test.domain.com\s$"
它重定向 anything.test.domain.com 和 anythingtest.domain.com(注意遗漏的一点)。我觉得应该是
HeadRequire "^Host:..test.domain.com\s$"
如果您只想重定向一级子域:
HeadRequire "^Host:[^.]+.test.domain.com\s*$"
如果你也想重定向 test.domain.com:
HeadRequire "^Host:([^.]+.)?test.domain.com\s*$"
关于linux - 英镑配置,通配符的 https 重定向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39100948/