uniq_

How to setup a apache reverse proxy for a vhost setup

# install apache2
sudo apt-get install libapache2-mod-proxy-html

# enable required apache mods
sudo a2enmod proxy
sudo a2enmod proxy_http

# create a new site definition eg.
cat << EOF | sudo bash -c 'cat >> /etc/apache2/sites-available/example.com'

<VirtualHost *:80>

  # domain for v-host resolving
  ServerName example.com
  ServerAlias example.com

  # no normal proxy function, only reverse proxying
  ProxyRequests Off

  # TODO find out what this is good for, it's certainly not required
  #<Proxy *>
  #  AddDefaultCharset Off
  #  Order deny,allow
  #  Allow from all
  #</Proxy>

  # might be interesting too
  #SSLProxyEngine on

  # defined forwarding targed
  ProxyPass / http://192.168.0.2/
  ProxyPassReverse / http://192.168.0.2/

</VirtualHost>

EOF


# enable the new site (the file name you chose for the revers proxy config)
sudo a2ensite example.com

# reload apache
sudo service apache2 reload

written by uniq on 2013-09-19