Reverse HTTP Proxy configuration

How to create a reverse HTTP Proxy AKA how to get the content from a webserver delivered by another one.

Problem: Web service is listening at serverA:8081. Client is behind a firewall which does not allow to connect to port 8081. Use a reverse proxy to move the service to port 80 at another serverB:



ServerName serverB
# Disable Forward Proxy, only Reverese Proxy needed
ProxyRequests Off

Order allow,deny
Allow from all

ProxyPass / http://serverA:8081/
ProxyPassReverse / http://serverA:8081/
ErrorLog /var/log/apache/serverB_error_log
CustomLog /var/log/apache/serverB_access_log combined

Notes:

  • serverB runs other web domains too so the proxy is encapsulated in a Virtual host.
  • Don't forget to enable the Apache modules proxy and proxy_http.

Update 2011-03-16:

There are other tools for just forwarding ports from one machine to another. For the problem described above I now use rinetd. The Apache Proxy is modifying the data stream - new lines where missing at some places.