Let's say I have a reverse proxy server (proxy) and a backend server actually handling the traffic (backend). I use a reverse SSH tunnel to send the traffic to the backend server.
So I setup the proxy server like this:
ProxyPass "/" "http://localhost:8080/"
ProxyPassReverse "/" "http://localhost:8080/"
I enabled the correct Apache modules, and all was good.
However, I noticed an issue. If I specified a redirect like so:
Redirect permanent /index.html /w/index.php
Accessing the backend server without the proxy causes the redirect to work correctly (e.g. http://backend redirects to http://backend/w/index.php), but accessing it through the proxy server causes it to redirect to http://localhost/w/index.php instead, which shouldn't be happening.
My SSH tunnel runs on the backend server, and looks something like this:
ssh -NT -R localhost:8080:localhost:80 proxy-server
Edit: I also tried using ProxyPreserveHost On on the proxy server, but what this seemed to do is redirect me from http://proxy to http://backend/w/index.php; this is not desired because the backend server will not be open to the public.
Would setting ServerName or creating a VirtualHost or something here help?