I have the following virtual host on my personal web server which runs on my NAS.I have dynDNS setup to redirect both mydomain.com and *.mydomain.com to my NAS.

<VirtualHost *:80>
    ServerName redir.example.com
    ProxyPass /pbay/ http://www.anothersite.example.com/
    ProxyPassReverse /pbay/ http://www.anothersite.example.com/

when I try to visit redir.example.com/pbay/,it is redirecting to www.anothersite.example.com/ and the address bar still shows redir.example.com/pbay/ as intended. But when I do anything on the site which results in another request to the server, the address bar is changing to real (anothersite.example.com) address. I want to always show only http://redir.example.com/.

I thought that is what ProxyPassReverse is for. How can I achieve this?

  • I wonder what pbay could be – Andrew Smith Jun 7 '15 at 14:31

You would also need to enable mod_proxy_html. ProxyPassReverse only rewrites the HTTP headers. To rewrite the content of the HTML (such as absolute links), you need to enable the additional module.

The documentation for ProxyPassReverse states this pretty clearly:

This directive lets Apache httpd adjust the URL in the Location, Content-Location and URI headers on HTTP redirect responses. This is essential when Apache httpd is used as a reverse proxy (or gateway) to avoid by-passing the reverse proxy because of HTTP redirects on the backend servers which stay behind the reverse proxy.

Only the HTTP response headers specifically mentioned above will be rewritten. Apache httpd will not rewrite other response headers, nor will it by default rewrite URL references inside HTML pages. This means that if the proxied content contains absolute URL references, they will by-pass the proxy. To rewrite HTML content to match the proxy, you must load and enable mod_proxy_html.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.