简体   繁体   English

WordPress站点的Apache反向代理不应该通过子路径

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

I've been trying to set up a reverse proxy on a main website to a blog site of the url format 我一直在尝试在主网站上将反向代理设置为url格式的博客网站

example.com/blog -> blog.example.com example.com/blog-> blog.example.com

example.com/blog is on an Apache instance and in the httpd.conf I have added the following. example.com/blog在Apache实例上,并且在httpd.conf中添加了以下内容。

SSLProxyEngine on

ProxyPreserveHost Off
ProxyRequests Off

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

This all works but it keeps 404ing. 所有这些都有效,但是仍然保持404状态。 The good news is it is actually reverse proxying correctly because it grabs the 404 page of the blog. 好消息是它实际上是正确的反向代理,因为它可以获取博客的404页。

After looking at the apache access logs I found that it is passing the subpath for whatever reason /blog to blog.example.com so its fetching blog.example.com/blog . 查看apache访问日志后,我发现它出于某种原因将子路径/blog传递给blog.example.com因此其获取blog.example.com/blog When users navigate to /blog , it does 404 naturally. 当用户导航到/blog ,它自然会执行404。 However, my understanding was when setting up ProxyPassReverse is it would make the request at what was specified so in my above case it should be requesting blog.example.com and not passing the /blog at the end. 但是,我的理解是在设置ProxyPassReverse ,它将按指定的内容发出请求,因此在我上面的情况下,它应该是请求blog.example.com而不是最后传递/blog

Here is the snippet from the documentation that confirms the above in how it should work: 以下是文档的片段,该片段确认了上面的工作方式:

For example, suppose the local server has address http://example.com/ ; 例如,假设本地服务器的地址为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). 不仅会导致对http://example.com/mirror/foo/bar的本地请求在内部转换为对http://backend.example.com/bar的代理请求(ProxyPass在此处提供的功能) 。

Any ideas why this might be? 任何想法为什么会这样? Worst case I might try to add a redirect or a rewrite so /blog goes to the homepage but I do have my permalinks set up in such a way that the /blog is in the slug of articles. 最坏的情况是我可能尝试添加重定向或重写,以使/blog转到主页,但我的永久链接的设置方式确实使/blog在文章中。

FYI I am using Apache 2.2. 仅供参考,我正在使用Apache 2.2。

I'm an idiot. 我是个白痴。 I was using ProxyPassMatch instead of ProxyPass . 我正在使用ProxyPassMatch而不是ProxyPass Ugh. 啊。

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

相关问题 Apache 后面的 WordPress 站点反向代理不断重定向到本地主机 - WordPress site behind Apache reverse proxy keeps redirecting to localhost 使用 NGINX 作为 apache 的反向代理时,Wordpress 永久链接返回 404 - Wordpress Permalinks return 404 when using NGINX as a reverse proxy to apache 带有反向NGINX代理的Docker中的WordPress站点部署 - WordPress Site Deployment in Docker with Reverse NGINX proxy Wordpress 使用反向代理时无法更新 - Wordpress can't update when using reverse proxy 在CentOS中使用Nginx作为Apache上Wordpress的反向代理 - Using Nginx as reverse proxy for wordpress on Apache in CentOS Nginx 反向 SSL 代理的问题 Apache 的 ZFDE31686817FE502906DB356 - Problems with Nginx Reverse SSL Proxy for Apache for WordPress 在 Caddy 反向代理后面的 Nginx 上提供 Wordpress 站点时的神秘重定向 - Mystifying redirects when serving Wordpress site on Nginx behind a Caddy reverse proxy WordPress(WooCommerce?)强制使用https(不应该使用) - Wordpress (WooCommerce?) forces https (when it shouldn't) 如何在反向代理服务器后面修复Wordpress网站的URL - How to fix urls of wordpress site behind reverse proxy server Azure web 应用程序无法反向代理到 Wordpress 站点 - Azure web apps fails to reverse proxy to Wordpress site
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM