Apache反向代理配置-子域

Apache反向代理配置-子域,apache,reverse-proxy,virtualhost,Apache,Reverse Proxy,Virtualhost,我正在尝试将Apache服务器配置为使用反向代理的2个子域。我能够将流量重定向到第一个子域(first.example.com),并成功地从https站点检索内容。然而,每当我尝试访问第二个子域时,我最终会从第一个子域获取内容,并且由于路由与我的本地网站不匹配,我会得到一个未找到的页面 我想知道我可以从当前配置中调整什么,以便从本地主机站点获取内容 以下是我当前的配置: <Proxy *> Require all granted </Proxy> SSLProxyEng

我正在尝试将Apache服务器配置为使用反向代理的2个子域。我能够将流量重定向到第一个子域(first.example.com),并成功地从https站点检索内容。然而,每当我尝试访问第二个子域时,我最终会从第一个子域获取内容,并且由于路由与我的本地网站不匹配,我会得到一个未找到的页面

我想知道我可以从当前配置中调整什么,以便从本地主机站点获取内容

以下是我当前的配置:

<Proxy *>
Require all granted
</Proxy>

SSLProxyEngine On
ProxyRequests Off
SSLProxyCheckPeerCN off
SSLProxyCheckPeerExpire off
SSLInsecureRenegotiation on
SSLProxyVerify none
SSLVerifyClient none
SSLProxyCheckPeerName off

<VirtualHost first.example.com:80>
    ServerName first.example.com
    ProxyPass /first https://stackoverflow.com
    ProxyPassReverse /first https://stackoverflow.com
    ProxyPassMatch ^/(.*)$ https://stackoverflow.com/$1

</VirtualHost>

<VirtualHost second.example.com:80>
    ServerName second.example.com
    ProxyPass /site http://localhost/site
    ProxyPassReverse /site http://localhost/site
    ProxyPassMatch ^/(.*)$ http://localhost/site/$1
</VirtualHost>

要求所有授权
SSLProxyEngine打开
代理请求关闭
SSLProxyCheckPeerCN关闭
SSLProxycheckpeer关闭
SSL安全协商
SSLProxyVerify无
SSLVERIFYCLENT无
SSLProxyCheckPeerName关闭
ServerName first.example.com
ProxyPass/firsthttps://stackoverflow.com
ProxyPassReverse/firsthttps://stackoverflow.com
ProxyPassMatch^/(.*)$https://stackoverflow.com/$1
ServerName second.example.com
代理通行证/站点http://localhost/site
ProxyPassReverse/站点http://localhost/site
ProxyPassMatch^/(.*)$http://localhost/site/$1
提前非常感谢

致以最良好的祝愿


埃德加·马丁内斯。

您当前的配置与自身冲突。并且做了相同的事情(在regex中),但是您用不同的规则声明了这两个

ProxyPass /site http://localhost/site
规则说:任何访问
http://second.example.com/site
将从
http://localhost/site
。如果您访问
http://second.example.com/foo
,你什么也得不到

赛线

ProxyPassMatch ^/(.*)$ http://localhost/site/$1
规则说:任何访问
http://second.example.com/site
将从
http://localhost/site/site
。如果您访问
http://second.example.com/foo
,您将获得
http://localhost/site/foo

如果您使用的是匹配版本(regex),那么对于没有regex版本的反向规则,您的运气也不好。不过,我不确定你是否真的需要相反的规则


至于为什么你的第二个请求得到了第一个请求的结果。。。我不知道。

Hello@Grumpy,你是对的,我的配置与自身冲突。我就是这样修改的:
NameVirtualHost*:80
DocumentRoot“F:/root/htmldocs”
服务器名second.example.com
ProxyPassReverse"/" "https://stackoverflow.com/“
感谢您抽出时间回答我的问题。