Apache 反向代理提供错误内容

Apache 反向代理提供错误内容

我在 HTTP 守护进程前面设置了一个 Apache 代理,该进程使用以下指令为 Sinatra Web 应用程序提供服务(效果很好)

ProxyPass / http://ip-ad-dr-ess:8080/
ProxyPassReverse / http://ip-ad-dr-ess:8080/

这让我可以浏览http://example.com并从守护程序 Web 服务器提供内容。我想将 wordpress 博客作为子目录添加到主站点中。

http://example.com <- Sinatra
http://example.com/blog <- Wordpress

这是整个配置部分

<IfModule mod_proxy_http.c>
LogLevel debug
ProxyRequests Off
ProxyPass /blog http://blog.example.com:80/
ProxyPassReverse /blog http://blog.example.com:80/
ProxyPass / http://ip-ad-dr-ess:8080/
ProxyPassReverse / http://ip-ad-dr-ess:8080/
<Location />
    RequestHeader set X-Forwarded-Protocol http
</Location>
<Location /blog>
    RequestHeader set X-Forwarded-Protocol http
</Location>
ProxyPreserveHost on
ProxyErrorOverride Off
</IfModule>

我遇到的问题是当我导航到http://example.com/blog我提供的内容来自 http://example.com不是来自 Wordpress。

作为测试,在上面的配置中我替换了http://blog.example.com:80/http://www.google.com:80/当我导航到http://example.com/blog我只是被重定向到 Google 的网站(使用地址栏中的 URL),这不是我所期望的行为。

关于为什么无法提供 WordPress 内容,有什么想法可以解决或进一步调试该问题?

谢谢

更新 blog.exmaple.com 摘录

<VirtualHost ip-ad-dr-ess:80>
ServerAdmin [email protected]
DocumentRoot /home/path/blog.example.com
ServerName www.blog.example.com
ServerAlias blog.example.com
DirectoryIndex index.html index.shtml index.htm Index.html Index.htm Index.shtml$
ErrorLog /home/path/logs/blog.example.com/http.20187367/error.log
Alias /stats /home/path/logs/blog.example.com/http.20187367/html
<Directory /home/path/logs/blog.example.com/http.20187367/html>
AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,Includes,Indexes$
</Directory>
Alias /doc/analog /usr/share/analog
RewriteEngine on
RewriteCond %{HTTP_HOST}  =www.blog.example.com       [NC]
RewriteRule ^(.*)         http://blog.example.com$1  [R=301,NE]
</VirtualHost>

答案1

您应该尝试在路径“/blog”后面添加一个斜杠,如下所示

ProxyPass /blog/ http://blog.example.com/
ProxyPassReverse /blog/ http://blog.example.com/

答案2

我能够解决这个问题。根本原因是我在同一个 IP 和同一个端口上设置了一个从一个虚拟主机到另一个虚拟主机的代理。

我改变了blog.example.com监听不同的端口,更新了代理值,http://example.com问题就解决了

相关内容