I've got about 5 web applications on different servers running on my LAN, which are all listening to port 80
I would like to make them accessible from the internet by setting up an Apache reverse proxy on my main webserver, which is running on Ubuntu 16.04
Changing their ports and then portfordwarding is not a really good option, since there are a bunch of devices that would need reconfiguration. Plus I would like to keep it user friendly, manually writing ports isn't
So basically, I want to redirect requests the following way:
www.mydomain.com/server3
should redirect to 192.168.1.3:80
www.mydomain.com/server4
should redirect to 192.168.1.4:80
And so on
For now, I followed these instructions:
https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension
After installing and enabling the requeried modules, I added the following lines to the `/etc/apache2/sites-enabled/000-default.conf' file:
<VirtualHost *:80>
ProxyPreserveHost On
# Servers to proxy the connection, or;
# List of application servers:
# Usage:
# ProxyPass / http://[IP Addr.]:[port]/
# ProxyPassReverse / http://[IP Addr.]:[port]/
# Example:
ProxyPass "/server3" "http://192.168.1.3:80"
ProxyPassReverse "/server3" "http://192.168.1.3:80"
ServerName pacs
</VirtualHost>
But it didn't have any effect, same goes for this:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://192.168.1.3:80
ProxyPassReverse / http://192.168.1.3:80
ServerName pacs
</VirtualHost>
Am I missing something?
Best Answer
The directive
ProxyPass "/server3" "http://192.168.1.3:80"
does not need the default port number 80 for HTTP and I would add a trailing slash:ProxyPass "/server3/" "http://192.168.1.3/
.As of the the 2.4 release the manual recommends the functionally identical syntax with the ProxyPass directive enclosed in a
<Location>
directive:after restarting requests to
http://pacs/server3/
should now be forwarded to 192.168.1.3, check the access log there to see them come in.Note: If the content on 192.168.1.3 for instance refers to /css/style.css your browser will interpret that and make a request to
http://pacs/css/style.css
which most likely fails as that resource is not covered by the reverse proxy.