Apache 虚拟代理,不要从 root 重定向

Apache virtual proxy, do not redirect from root

我的 vhosts.conf 中有以下内容:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName ci.myserver.com
    ProxyRequests Off
    ProxyPreserveHost On

    ProxyPass / ajp://127.0.0.1:8009/
    ProxyPassReverse / ajp://127.0.0.1:8009/
    ProxyPassReverseCookiePath / /
</VirtualHost>

现在,当我访问我的根 (myserver.com) 时,我得到了我的 Jenkins,当我访问 ci.myserver.com

时也是如此

如何在我访问 myserver.com 时不重定向到 CI,而只使其适用于 ci。myserver.com

更新版本

这解决了一个问题。

<VirtualHost *:80>
    ServerName ci.myserver.com
    ProxyRequests Off
    ProxyPreserveHost On

    ProxyPass / ajp://127.0.0.1:8009/
    ProxyPassReverse / ajp://127.0.0.1:8009/

    ProxyPassReverseCookiePath / /
</VirtualHost>


<VirtualHost *:80>
    ServerName myserver.com
    DocumentRoot /

    <Directory />
        Require all granted
    </Directory>
</VirtualHost>

您需要创建另一个 VirtualHost,否则解析您服务器 ip 的主机名将达到默认值 VirtualHost,在您的情况下是 ci.myserver.com.

向文件添加另一个:

<VirtualHost *:80>
    ServerName myserver.com
    DocumentRoot /path/to/root

    <Directory /path/to/root>
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>