Apache as a reverse proxy

Instead of opening a bunch of ports to my home network, i figured it was easier to setup a reverse proxy for all the servers in my home. Heres a quick run down on how to do it.

First we have to enable the proxy modules in apache then restart apache.

sudo ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled
sudo ln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled

sudo /etc/init.d/apache2 restart

Once that is complete we need to create the apache config we will be using.

sudo vim /etc/apache2/sites-available/proxiedhosts

Here is an example of one host in my network, you need to add your hosts like this.

<VirtualHost *:80>
ServerName test.home.x.me
ProxyPass / http://192.168.x.x/
ProxyPassReverse / http://192.168.x.x/
<Proxy http://192.168.x.x/>
Order Allow,Deny
Allow from all

All you need to do is change the “ServerName” to that of the address you are coming in to and obviously the IP address.

There are a couple of situations where you need to additional options, running JIRA behind a reverse proxy is one of them. Here is a copy of my JIRA proxy config.

<VirtualHost *:80>
ServerName jira.home.*.me
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://192.168.*.*:8080/
ProxyPassReverse / http://192.168.*.*:8080/
<Proxy http://192.168.*.*:8080/>
Order Allow,Deny
Allow from all<

Note that additional “ ProxyRequests Off” and also the “ProxyPreserveHost On”