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: 18.104.22.168
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://22.214.171.124/vmwebapp in the host network.