0

我有一个 Apache 服务器充当反向代理,其中配置了两个相同的虚拟主机:server1 和 server2(见下文)。server2.mydomain.com 的 CNAME DNS 记录指向 server1.mydomain.com。当我点击 http:// server1 .mydomain.com/some/resource 时,后端服务器会看到一个包含server2 .mydomain.com 的 X-Forwarded-Host 标头。这是一个错误还是我的配置不正确?

谢谢。

-b

这是我的虚拟主机的样子:

非 SSL(重写为 SSL)

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName server1.mydomain.com
    ServerAlias server1
    ServerSignature off

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName server2.mydomain.com
    ServerAlias server2
    ServerSignature off

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

SSL

<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName server1.mydomain.com
    ServerSignature off

    DocumentRoot ...

    <Directory ... />

    Header        edit Location ^http:(.*)$ https:$1
    RequestHeader set X-Forwarded-Proto https

    ProxyVia off
    ProxyRequests Off
    ProxyPreserveHost On

    SSLProxyEngine On
    ProxyPass / https://back-end.mydomin.com/
    ProxyPassReverse / https://back-end.mydomain.com/

    ...
<VirtualHost>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName server2.mydomain.com
    ServerSignature off

    DocumentRoot ...

    <Directory ... />

    Header        edit Location ^http:(.*)$ https:$1
    RequestHeader set X-Forwarded-Proto https

    ProxyVia off
    ProxyRequests Off
    ProxyPreserveHost On

    SSLProxyEngine On
    ProxyPass / https://back-end.mydomin.com/
    ProxyPassReverse / https://back-end.mydomain.com/

    ...
<VirtualHost>
4

1 回答 1

1

我的错。我有重叠的 SSL 虚拟主机(当我启动/停止 Apache 时没有注意到警告)。解决方案是将NameVirtualHost *:443添加到 ports.conf

-b

于 2013-11-05T15:23:41.587 回答