Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 23rd February 2009, 05:01
atjensen11 atjensen11 is offline
Senior Member
 
Join Date: Dec 2007
Posts: 199
Thanks: 9
Thanked 6 Times in 6 Posts
Default Running two webservers on same network

Hello,

Some time ago, I built a Linux server using one of the excellent How-To articles here on the site. The server currently handles email, web, ftp, and DNS traffic.

I am getting close to bringing a new machine online to replace the existing machine.

In order to slowly migrate services over to the new machine, I was curious if it is possible to run two web servers on the same network. I know it is quite possible to configure them to run on different ports and then forward ports on the gateway router appropriately. This is not the desired functionality I want. Rather, I want the services to run on the default port (i.e. 80).

Research online has led me to believe it is possible by configuring a reverse proxy. I have seen many examples of High Availability clusters that operate in a similar but different fashion. The examples I have found all appear to deal with one domain where some URL's are sent to a server for the sales department and others are sent to a marketing server.

I have not yet found documentation or examples on how to have a proxy server effectively pass traffic to a backend server based on unique domains.

Any input would be appreciated.
Reply With Quote
Sponsored Links
  #2  
Old 24th February 2009, 19:03
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,739 Times in 2,574 Posts
Default

You can do that with Apache's reverse proxy feature (see http://www.howtoforge.com/apache_rev...roxy_ispconfig or http://www.howtoforge.com/load_balan...proxy_balancer ) or with Squid: http://www.howtoforge.com/how-to-set...on-debian-etch
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 6th March 2009, 17:41
stefanos stefanos is offline
Junior Member
 
Join Date: Nov 2008
Posts: 29
Thanks: 6
Thanked 1 Time in 1 Post
Thumbs up

Hi,

Apologies for bringing this post back to life. I came across the same issue in a different form.

I am running A perfect server Debian Lenny, and I have also installed VMware. I need VMware as a backup solution for another server.

It struck me that how would it be possible to run 2 web servers both on port 80.

Falko pointed me in the direction of mod_proxy. I think I found a solution here:

http://httpd.apache.org/docs/2.0/vho...les.html#proxy

Quote:
Using Virtual_host and mod_proxy together

The following example allows a front-end machine to proxy a virtual host through to a server running on another machine. In the example, a virtual host of the same name is configured on a machine at 192.168.111.2. The ProxyPreserveHost On directive is used so that the desired hostname is passed through, in case we are proxying multiple hostnames to a single machine.

<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://192.168.111.2/
ProxyPassReverse / http://192.168.111.2/
ServerName hostname.example.com
</VirtualHost>
Only problem now for me would be integrating this within ispconfig 3

I hope this helps.
Stephen
Reply With Quote
  #4  
Old 7th October 2009, 04:42
reason8 reason8 is offline
Senior Member
 
Join Date: Aug 2008
Posts: 141
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by falko View Post
How do any of those three options work to allow a second webserver running ISPConfig 3 to run on port 80 along with a primary ISPConfig webserver?

Must all 3 options be implemented or would any one of them work?
__________________
Running:

ISPConfig 3
openSUSE Linux 11.3
Reply With Quote
  #5  
Old 9th October 2009, 15:51
stefanos stefanos is offline
Junior Member
 
Join Date: Nov 2008
Posts: 29
Thanks: 6
Thanked 1 Time in 1 Post
Default

Hi reason8,

The way I understand it works is if you have a front end webserver that accepts all HTTP requests and then forwards it on as per your hosts file (or your internal DNS server).

My VirtualHost config looks like this:
<VirtualHost *:80>
ServerName www.server1.com
ServerAlias server1.com

ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass / http://www.server1.com/
ProxyPassReverse / http://www.server1.com/
</VirtualHost>

I have put the domains in the hosts file with the server ip as follows.

i.e.
/etc/hosts
192.168.1.11 www.server1.com
192.168.1.12 www.server2.com

You need to do it this way as the servers (192.168.1.11 & 192.168.1.12) need the host address to be passed in the GET request.

Personaly I run ISPconfig on a different port number but I have 4 vmware servers working (3 X Debian Lenny, 1 X Ubuntu), 1 is the front end Rev Proxy server that has a FIREWALL installed etc...

I think I did it with :
http://www.howtoforge.com/apache_rev...roxy_ispconfig
and with referance:
http://httpd.apache.org/docs/2.0/vho...les.html#proxy

Kind regards
Stephen
Reply With Quote
  #6  
Old 9th October 2009, 20:37
reason8 reason8 is offline
Senior Member
 
Join Date: Aug 2008
Posts: 141
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Stephen,

Thanks for your response to this message. I really appreciate it.

I am running ISPConfig 3 on OpenSuse 11.1
The problem that I had with the document for the apache reverse proxy is that on several parts of the process, some of the files were different for SuSe and when I did resolve these problems, the code inside of the files were not the same as the how to document. Such as the config.inc.php file:

[...]
if(isset($_SERVER['HTTP_HOST'])){
$go_info["server"]["server_url"] = 'http://'.$_SERVER['HTTP_HOST'];
} else {
$go_info["server"]["server_url"] = "http://ispconfig.example.com:81";
}
[...]

The above was no where to be found in my config.inc.php (which was located in two different directories).

Also, for your /etc/hosts config, what do you put for X.X.X.11 when that server has multiple websites (called virtual hosts?) located on it? My main webserver is hosting a few different websites so what would I put in this file for the primary server? Could I simply put "localhost" or should I put the name of the server itself?

Do you have any experience with OpenSuSe?

Thanks again!

Ray

*UPDATE*

I implemented your example and when it runs the configuration file from the /etc/apache2/vhosts.d/example.conf file, I get an error of :
Syntax error on line 5 of /etc/apache2/vhosts.d/example.conf:
Invalid command 'ProxyRequests', perhaps misspelled or defined by a module not included in the server configuration.

I have researched correcting this problem by making sure apache2-mod_proxy_html is installed (it is).
I tried using the LoadModule directive in httpd.conf but I get an error that it can not find the mod_proxy.so file in /srv/www
The file is in fact located in these two directories:

/usr/lib/apache2-prefork/mod_proxy.so
/usr/lib/apache2/mod_proxy.so

So I am at a stand still.

Is anyone else having (or had) this problem with this ProxyRequests error?
Any help would be appreciated.

*UPDATE*

I resolved the proxyreverse off error. I needed to install mod_proxy and not apache2_mod_proxy. This seems to have resolved the issue other than needing to change a shared objects link in the mod_proxy_html.conf file.

Not the problem I am having (which I was having before) is that there are no lines in:
/usr/local/ispconfig/interface/lib/config.inc.php
/usr/local/ispconfig/interface/lib/config.inc.php~
/usr/local/ispconfig/server/lib/config.inc.php

which are look like the following:
[...]
if(isset($_SERVER['HTTP_HOST'])){
$go_info["server"]["server_url"] = 'http://'.$_SERVER['HTTP_HOST'];
} else {
$go_info["server"]["server_url"] = "http://ispconfig.example.com:81";
}
[...]

as per the documentation on http://www.howtoforge.com/apache_rev...roxy_ispconfig

Am I looking at the wrong file? I am on a OpenSuse server versus a debian but I would assume that the config.inc.php file would be the same on all distros. Am I incorrect in my assumption?
__________________
Running:

ISPConfig 3
openSUSE Linux 11.3

Last edited by reason8; 10th October 2009 at 02:11. Reason: config.inc.php configuration question
Reply With Quote
  #7  
Old 12th October 2009, 10:43
stefanos stefanos is offline
Junior Member
 
Join Date: Nov 2008
Posts: 29
Thanks: 6
Thanked 1 Time in 1 Post
Default

Hi,

Sorry I cannot help with the config.inc.php. However I think that there is an option when you install as to what port to run on. As I said I left mine on port 81 (but this should not be a problem if the RevProxy is working as you can RevProxy for IspConfig to port 81 on your internal server. So I would leave this alone and do it via the RevProxy.

i.e.:
.....
ProxyPass / http://www.server1.com:81/
ProxyPassReverse / http://www.server1.com:81/

As for the /etc/hosts this is the anoying part every time you add a new site in ISPConfig you need to conf the RevProxy server to point to the new host.

i.e. add in the /etc/hosts the line to the server
eg:
192.168.1.12 auth.server1.com auth
192.168.1.11 www.server1.com server1.com
192.168.1.11 album.server1.com
192.168.1.11 server2.com www.server2.com

you also need to create the new vhosts file (/etc/apache2/sites-available) and run:
a2ensite server3.vhost

And don't forget you will need to restart Apache!!
Reply With Quote
  #8  
Old 19th October 2009, 09:35
reason8 reason8 is offline
Senior Member
 
Join Date: Aug 2008
Posts: 141
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by stefanos View Post
Hi,

Sorry I cannot help with the config.inc.php. However I think that there is an option when you install as to what port to run on. As I said I left mine on port 81 (but this should not be a problem if the RevProxy is working as you can RevProxy for IspConfig to port 81 on your internal server. So I would leave this alone and do it via the RevProxy.

i.e.:
.....
ProxyPass / http://www.server1.com:81/
ProxyPassReverse / http://www.server1.com:81/

As for the /etc/hosts this is the anoying part every time you add a new site in ISPConfig you need to conf the RevProxy server to point to the new host.

i.e. add in the /etc/hosts the line to the server
eg:
192.168.1.12 auth.server1.com auth
192.168.1.11 www.server1.com server1.com
192.168.1.11 album.server1.com
192.168.1.11 server2.com www.server2.com

you also need to create the new vhosts file (/etc/apache2/sites-available) and run:
a2ensite server3.vhost

And don't forget you will need to restart Apache!!
Ok. I think I got it up and running. I didnt run a2ensite though. I dont know if this matters or not but it seems like the forwarding is working (even for the ports). My question is, do you need to have vhost (server.conf) files on BOTH servers or just the primary? Currently I have them on both but I am unsure if this is necessary.

Thanks!
__________________
Running:

ISPConfig 3
openSUSE Linux 11.3
Reply With Quote
  #9  
Old 20th October 2009, 11:10
stefanos stefanos is offline
Junior Member
 
Join Date: Nov 2008
Posts: 29
Thanks: 6
Thanked 1 Time in 1 Post
Default

Hi Reason8,

That is good news if it's working.

What I did was point port 80 from my ADSL router to one of my internal webservers and made sure that it was working as it was ment to. If you are vhosts on your internal server make sure it works.

I then built the my front end RevProxy server as per above and changed my ADSL router to point to the new front end Revproxy server.

So in short, make sure your back end servers works as normal as if each is was itself a front end server then do not touch them. Then configure the RevProxy server to forward requests to your internal server. You should end up with your normal webserver conf files on your internal servers and the

Quote:
<VirtualHost *:80>
ServerName www.server1.com
ServerAlias server1.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://www.server1.com/
ProxyPassReverse / http://www.server1.com/
</VirtualHost>
conf's on your front end server and that is it.

If it helps this is my conf file of one of my internal servers:

Quote:
<Directory /var/www/server1.com>
AllowOverride None
Order Deny,Allow
Deny from all
</Directory>

<VirtualHost *:80>
DocumentRoot /var/www/server1.com/web

ServerName server1.com
ServerAlias www.server1.com
ServerAdmin webmaster@server1.com

ErrorLog /var/log/ispconfig/httpd/server1.com/error.log

<Directory /var/www/server1.com/web>
Options FollowSymLinks
AllowOverride Indexes AuthConfig Limit
Order allow,deny
Allow from all
<Files ~ '.php[s3-6]{0,1}$'>
Order allow,deny
Deny from all
Allow from none
</Files>
</Directory>
<Directory /var/www/clients/client1/web2/web>
Options FollowSymLinks
AllowOverride Indexes AuthConfig Limit
Order allow,deny
Allow from all
<Files ~ '.php[s3-6]{0,1}$'>
Order allow,deny
Deny from all
Allow from none
</Files>
</Directory>

# cgi enabled
<Directory /var/www/clients/client1/web2/cgi-bin>
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /var/www/clients/client1/web2/cgi-bin/
AddHandler cgi-script .cgi
AddHandler cgi-script .pl

</VirtualHost>
And ofcourse the hosts file:
Quote:
192.168.1.12 auth.server1.com auth
192.168.1.11 www.server1.com server1.com
192.168.1.11 album.server1.com
192.168.1.11 server2.com www.server2.com
hope it helps
Stephen
Reply With Quote
  #10  
Old 21st October 2009, 13:28
reason8 reason8 is offline
Senior Member
 
Join Date: Aug 2008
Posts: 141
Thanks: 2
Thanked 0 Times in 0 Posts
 
Default

Quote:
Originally Posted by stefanos View Post
Hi Reason8,

That is good news if it's working.

What I did was point port 80 from my ADSL router to one of my internal webservers and made sure that it was working as it was ment to. If you are vhosts on your internal server make sure it works.

I then built the my front end RevProxy server as per above and changed my ADSL router to point to the new front end Revproxy server.

So in short, make sure your back end servers works as normal as if each is was itself a front end server then do not touch them. Then configure the RevProxy server to forward requests to your internal server. You should end up with your normal webserver conf files on your internal servers and the



conf's on your front end server and that is it.

If it helps this is my conf file of one of my internal servers:



And ofcourse the hosts file:


hope it helps
Stephen
Stephen,

Some how I broke the rev proxy (had 2 putty windows opened and removed mod_proxy from the front end and now apache will not reload).

What do you have for your httpd.conf file for LoadModules and your mod_proxy_html.conf file?

Did you install apache2_mod_proxy (RPM or source) or just mod_proxy? Or did you install either of them?

Also, what is server3.vhost you were referring to? And to be clear, you have a configuration file on the second (internal server) as well? Where does this file go? What is the naming convention for it? Why do you have it pointing to server1 directory (on your local machine). Isnt server 1 on the front end proxy?

This is driving me nuts. I think I have a few more grey hairs

Thanks!
__________________
Running:

ISPConfig 3
openSUSE Linux 11.3
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fedora 4 TPS mail problem Hagforce HOWTO-Related Questions 13 10th February 2010 18:23
Slow network performance reading data JoeySpace Installation/Configuration 2 10th April 2007 17:42
WARNING: services not running MicCo Installation/Configuration 31 4th September 2006 12:16
network not really running blackflag Installation/Configuration 2 9th May 2006 01:12
Perfect Xen 3.0 setup for Debian gurneyzap HOWTO-Related Questions 4 26th March 2006 11:30


All times are GMT +2. The time now is 06:38.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.