2 Web Servers, 1 IP

Alles, was den Apache betrifft, kann hier besprochen werden.

2 Web Servers, 1 IP

Postby 37Seconds » 21. June 2010 19:55

I have 2 web servers (both linux) configured and running perfectly independently. The first (my main web server) is used to host my main website and the second is another linux distribution that I have a specific application installed on (couldn't get the application working on my main box). I only have 1 IP and I need both to use the same port (80).

I would like to know how to setup the apache configuration on the main box to pass traffic for a particular domain name to the other webserver. Can anyone help with this?

Thanks!
37Seconds
 
Posts: 2
Joined: 21. June 2010 19:48

Re: 2 Web Servers, 1 IP

Postby Nobbie » 21. June 2010 22:49

Edit httpd.conf (or extra/httpd-vhost.conf and include it in httpd.conf) from main server and insert following lines:

Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName main.domain.com    <== replace by domain name for main server
DocumentRoot /var/www            <== replace by your document root folder
....                                            <== add standard permissions and options as needed for main server
</VirtualHost>

<VirtualHost *:80>
ServerName second.domain.com  <== replace by domain name for second server
ProxyPass / http://xxx.xxx.xxx.xxx/   <== replace xxx.xxx.xxx.xxx by LAN IP of second server
ProxyPassReverse / http://xxx.xxx.xxx.xxx/    <== again  replace xxx.xxx.xxx.xxx by LAN IP of second server (i.e. 192.168.1.2 or similar)
</VirtualHost>


Read the documentation about VirtualHost and about Reverse Proxy.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: 2 Web Servers, 1 IP

Postby 37Seconds » 23. June 2010 15:19

Thanks Nobbie. I thought it had something to do with reverse proxy, but since my application requires the specific hostname in the URL, I didn't think it would work. After doing as you described, then also adding the ProxyPreserveHost directive, I was able to achieve what I needed.

Thanks again.
37Seconds
 
Posts: 2
Joined: 21. June 2010 19:48


Return to Apache

Who is online

Users browsing this forum: No registered users and 21 guests