繁体   English   中英

Apache反向代理配置-子域

[英]Apache Reverse Proxy configuration - Subdomains

我正在尝试将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>

提前非常感谢您!

最好的祝福!

埃德加·马丁内斯(EdgarMartínez)。

您当前的配置与其自身冲突。 ProxyPassProxyPassMatch执行相同的操作(在正则表达式中),但是您使用不同的规则对其进行了声明。

ProxyPass /site http://localhost/site

Rule说:访问http://second.example.com/site任何人都将从http://localhost/site 如果您访问http://second.example.com/foo ,您将一无所获。

比赛线

ProxyPassMatch ^/(.*)$ http://localhost/site/$1

Rule说:访问http://second.example.com/site任何人都将从http://localhost/site/site 如果您访问http://second.example.com/foo ,则会得到http://localhost/site/foo

如果您使用匹配版本(regex),则对于没有正则表达式版本的反向规则也很不走运。 不过,我不确定您是否确实需要相反的规则。

至于为什么您的第二个请求是第一个请求的结果...我不知道。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM