WordPress – Apache Reverse Proxy Serving Wrong Content

apache-2.2redirectreverse-proxyWordpress

I have an Apache Proxy setup in front of an HTTP daemon process that serves a Sinatra web application with the following Directives (which work great)

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

This allows me to browse http://example.com and served the content from the daemon web server.
I would like to include a wordpress blog as a subdirectory to the main site.

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

Here is the entire config section

<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>

The problem I am having is when I navigate to http://example.com/blog I am served content from http://example.com not from the WordPress.

As a test, in the config above I replaced http://blog.example.com:80/ with http://www.google.com:80/ and when I navigate to http://example.com/blog I am simply redirected to Google's site (with the URL in the address bar) which is not the behavior I expected.

Any idea of how I can resolve or maybe further debug this issue as to why the wordpress content is not be served?

Thanks

Update blog.exmaple.com excerpt

<VirtualHost ip-ad-dr-ess:80>
ServerAdmin webmaster@blog.example.com
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>

Best Answer

You should try adding a trailing slash the path "/blog" like this

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