Here is a small scenario where you would like to configure an Apache Reverse proxy.
You are having a server with a public IP and apache is running on it.Now you want to host your applications on LAN and also want them to be accessible on internet the important part is these applications are still running on the machines on LAN.
let say the websites are :
a)internal1.example.com should map to internal1.example.com
b)internal2.example.com should map to internal2.example.com
c)internal3.example.com should point to internal3 .example.com
d)internal4.example.com should point to internal4 .example.com
Following is network configuration
|--------------192.168.1.3 | (internal3.example.com) | |--------------192.168.1.4 | (internal4.example.com) (Public IP ) | A--------------| (reverse proxy server) | (192.168.1.25) | example.com | |--------------192.168.1.1 | (internal1.example.com) | |--------------192.168.1.2 | (internal2.example.com)
I am using Ubuntu to host Apache the vhost definition in case of Debian based systems the definiton of websites is done on
/etc/apache2/sites-enabled/*.conf
where *conf corresponds to
internal1.conf internal2.conf internal3.conf internal4.conf
The vhost definition of each of these sites will be as follows
/etc/apache2/sites-enabled/internal1.example.conf
<virtualhost *:80> ServerAdmin webmaster@localhost ServerName internal1.example.com ProxyRequests off <proxy *> Order deny,allow Allow from all </proxy > ProxyPass / http://192.168.1.1/ ProxyPassReverse / http://192.168.1.1/ </VirtualHost >
/etc/apache2/sites-enabled/internal2.example.conf
<virtualhost *:80> ServerAdmin webmaster@localhost ServerName internal2.example.com ProxyRequests off <proxy *> Order deny,allow Allow from all </proxy > ProxyPass / http://192.168.1.2/ ProxyPassReverse / http://192.168.1.2/ </VirtualHost >/etc/apache2/sites-enabled/internal3.example.conf
<virtualhost *:80> ServerAdmin webmaster@localhost ServerName internal3.example.com ProxyRequests off <proxy *> Order deny,allow Allow from all </proxy > ProxyPass / http://192.168.1.3/ ProxyPassReverse / http://192.168.1.3/ </VirtualHost >
/etc/apache2/sites-enabled/internal4.example.conf
<virtualhost *:80> ServerAdmin webmaster@localhost ServerName internal4.example.com ProxyRequests off <proxy *> Order deny,allow Allow from all </proxy > ProxyPass / http://192.168.1.4/ ProxyPassReverse / http://192.168.1.4/ </VirtualHost >
Note in all of the above vhost definitions I have dropped the options of Log files.
So if you apply to a production server add them in each of the vhost file.
Above is just to give you a clear cut example as how it can be working.
I run a very complex Apache setup so above is just a small example to help you.
Rest of the details can vary depending upon your configurations.
No comments:
Post a Comment