到 Wordpress 站点的 Apache 反向代理在不应该传递子路径时传递子路径

Apache Reverse Proxy to a Wordpress site passes subpath when it shouldn't

我一直在尝试在主网站上设置反向代理到 url 格式的博客网站

示例。com/blog -> blog.example.com

示例。com/blog 在 Apache 实例上,在 httpd.conf 我添加了以下内容。

SSLProxyEngine on

ProxyPreserveHost Off
ProxyRequests Off

ProxyPassMatch /blog https://blog.example.com
ProxyPassReverse /blog https://blog.example.com

这一切都有效,但它保持 404ing。好消息是它实际上是正确的反向代理,因为它抓取了博客的 404 页面。

查看 apache 访问日志后,我发现它出于某种原因将子路径 /blog 传递给 blog.example.com,因此它正在获取 blog.example.com/blog。当用户导航到 /blog 时,它会自然地执行 404。但是,我的理解是在设置 ProxyPassReverse 时它会按照指定的内容发出请求,所以在我上面的例子中它应该请求 blog.example.com 而不是最后传递 /blog

这是文档中的片段,它证实了上面的工作原理:

For example, suppose the local server has address http://example.com/; then

ProxyPass /mirror/foo/ http://backend.example.com/
ProxyPassReverse /mirror/foo/ http://backend.example.com/
ProxyPassReverseCookieDomain backend.example.com public.example.com
ProxyPassReverseCookiePath / /mirror/foo/

will not only cause a local request for the http://example.com/mirror/foo/bar to be internally converted into a proxy request to http://backend.example.com/bar (the functionality which ProxyPass provides here).

知道为什么会这样吗?最坏的情况是,我可能会尝试添加重定向或重写,因此 /blog 会转到主页,但我确实以 /blog 位于文章段中的方式设置了我的永久链接。

仅供参考,我使用的是 Apache 2.2。

我是个白痴。我使用的是 ProxyPassMatch 而不是 ProxyPass。呃.