linux - 英镑配置,通配符的 https 重定向问题

标签 linux https load-balancing pound

我遇到一个问题,即 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/

相关文章:

regex - grep 正则表达式搜索数字序列

linux - 检查可用的处理核心

node.js - 使用 ssl 保护来自 Node 的服务调用

ssl - Yaws 网络服务器通过 HTTP 运行,但不通过 HTTPS

linux - 检查 Varnish 4 中超过 2 个 Web 服务器的后端健康状况

javascript - NodeJS 中的集群

应用程序中是否可以存在相同库(具有相同名称)的两个不同版本?

linux - 在 jar 中查找特定路径

javascript - HTTP header 使浏览器显示 "save as"对话框并保存文件

load-balancing - 负载均衡器是否需要负载均衡器?