I have one public IP address linked to Apache on Ubuntu through a NAT modem. How do I configure Apache to serve pages from other machines which are also behind the same NAT modem? (I do not want to make these other machines directly accessible from the internet.)
Asked
Active
Viewed 1,039 times
0
-
It seems to me that you want to know how to configure Apache (partly) as a proxy and that the problem has little to do with NAT. – Hauke Laging Mar 16 '13 at 12:40
-
The NAT part of the problm is that the other machines must not be resolvable from the internet. I want to use the first machine to add a degree of security to the second. – Frank Mar 16 '13 at 13:24
1 Answers
1
I'm using apache proxy for this.
Example virtualhost configuration, which proxies requests to another webserver is this:
<VirtualHost *:80>
ServerName example.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://secondapache/
ProxyPassReverse / http://secondapache/
</VirtualHost>
Where "secondapache" needs to be resolvable, or you can use IP address, just make sure it's the same in ProxyPass and ProxyPassReverse lines (don't forget those http:// and /)
Also ProxyPreserveHost On is needed so that second webserver gets the real hostname user entered into browser.
That was for apache HTTP reverse proxy, you can also use for example varnish to configure HTTP reverse proxy.
Another method would be simply using NAT:
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination secondapacheIP:80

Kveri
- 161
- 4