Apache – ProxyPass

I got a virtual machine which is installed with Apache. Normally, the virtual machine can only be accessed by the host computer. So how could i open the virtual machine service to the entire host network but not limited to the host computer?

This can be done by the Apache ProxyPass. Here is an example of setting up the ProxyPass

Assume we have the following initial configuration.


1. Apache/2.2.9 is installed in the host computer
2. A web application is running on the virtual machine
3. Host computer IP: 199.8.76.54
4. Virtual machine IP: 192.168.1.128
5. http://192.168.1.128/vmwebapp can only be accessed by the host computer

Our goal: Make the vmwebapp accessible by other machines in the host network

ProxyPass configuration @ host computer


1. Enable the apache modules for the ProxyPass (needs root privilege)
a2enmod proxy
a2enmod proxy_http

2. Create a new file at /etc/apache2/conf.d/proxypass.conf with the following setting

# ProxyPass configuration for vmwebapp
ProxyPass /vmwebapp http://192.168.1.128/vmwebapp
ProxyPassReverse /vmwebapp http://192.168.1.128/vmwebapp
<Location /vmwebapp>
        Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
        Order deny,allow
        Allow from all
</Location>

3. Restart the Apache
/etc/init.d/apache2 restart

You can now accessed the vmwebapp thru http://199.8.76.54/vmwebapp in the host network.

Done. =)

4 thoughts on “Apache – ProxyPass”

  1. This work *perfectly*. Simple and easy without over explanation. I needed this specifically because I have a windows virtual machine running a webapp (subsonic) while another virtual machine (ubuntu server) has apache with other web services. I didn’t want to have to specify the port of the other VM in the url, and this was the perfect fix. Thank you!

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.