Replacing hyperlinks in Apache2 ProxyPass
- by Jeroen
I am using Apache2 with mod proxy on Ubuntu 12.04 as a reverse proxy to some back-end server:
<VirtualHost *:80>
ProxyPass / http://somewhere.com/mysite
ProxyPassReverse / http://somewhere.com/mysite
ServerName www.mysite.nl
ServerAlias mysite.nl *.mysite.nl
</VirtualHost>
However, unfortunately the back-end server has some internal links hardcoded; e.g. a link to somewhere else in the site has <a href="http://somewhere.com/mysite/something"> instead of just <a href="something.png">. Is there a way I can use Apache to replace strings in the body as served by the backend before passing it back to the client? E.g replace all instances of "http://somewhere.com/site/" with "http://mysite.nl/" ?
I know nginx or so is better as a reverse proxy, but the server is hosting other stuff so port 80 needs to be Apache2.