You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Peter B <jc...@hotmail.com> on 2011/07/18 21:20:15 UTC

[users@httpd] Virtual Hosts on physical servers

Hi All,

I'm setting up some servers for web hosting (they are vbox virtual servers) and need a little help with virtual hosts.

I could find examples on how to set up virtual hosts for most scenarios, but not my one, which is as follows:

I have a single IP address, with multiple web servers, so I somehow need www.hello.com to go to server1 and www.test.com to go to server2.

I know I can do this with NAT, but having to have people type www.hello.com:81 and www.test.com:82 is ugly, so is there a way apache can do this for me?

--Pete
 		 	   		  

RE: [users@httpd] Virtual Hosts on physical servers

Posted by Peter B <jc...@hotmail.com>.
Hi Pete,

I checked out that page, but that only covers virtual hosts on the same server, not other servers.

> Date: Mon, 18 Jul 2011 20:35:52 +0100
> From: ph1@openstrike.co.uk
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] Virtual Hosts on physical servers
> 
> Hello,
> 
> It sounds like you want name-based virtual hosts. See
> http://httpd.apache.org/docs/2.2/vhosts/name-based.html
> 
> Pete
> 
> On Tue, Jul 19, 2011 at 07:20:15AM +1200, Peter B wrote:
> > 
> > I have a single IP address, with multiple web servers, so I somehow need www.hello.com to go to server1 and www.test.com to go to server2.
> > 
> > I know I can do this with NAT, but having to have people type www.hello.com:81 and www.test.com:82 is ugly, so is there a way apache can do this for me?
> 
> -- 
> Openstrike - improving business through open source
> http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107
 		 	   		  

RE: [users@httpd] Virtual Hosts on physical servers

Posted by Peter B <jc...@hotmail.com>.
Thanks Dave, I'll check this out.

> Date: Mon, 18 Jul 2011 13:20:59 -0700
> From: geek@uniserve.com
> To: users@httpd.apache.org; ph1@openstrike.co.uk
> Subject: Re: [users@httpd] Virtual Hosts on physical servers
> 
> Quoting Pete Houston <ph...@openstrike.co.uk>:
> 
> > Content-Type: text/plain; charset=us-ascii
> > Content-Disposition: inline
> > Content-Transfer-Encoding: quoted-printable
> >
> > Hello,
> >
> > It sounds like you want name-based virtual hosts. See
> > http://httpd.apache.org/docs/2.2/vhosts/name-based.html
> >
> > Peter
> 
> For several years now I've been using virtualmin for just this  
> situation, a lovely and largely automated management tool. Available  
> with full function as GPL code and with extra bits in the for pay  
> VM-Pro version.
> 
> Dave
> 
> >
> > On Tue, Jul 19, 2011 at 07:20:15AM +1200, Peter B wrote:
> >>
> >> I have a single IP address, with multiple web servers, so I somehow  
> >> need www.hello.com to go to server1 and www.test.com to go to  
> >> server2.
> >>
> >> I know I can do this with NAT, but having to have people type  
> >> www.hello.com:81 and www.test.com:82 is ugly, so is there a way  
> >> apache can do this for me?
> >
> > --
> > Openstrike - improving business through open source
> > http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107
> >
> 
> 
> 
> -- 
> "It is no measure of health to be well adjusted to a profoundly sick society."
>    Krishnamurti
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
 		 	   		  

Re: [users@httpd] Virtual Hosts on physical servers

Posted by Dave Stevens <ge...@uniserve.com>.
Quoting Pete Houston <ph...@openstrike.co.uk>:

> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> Content-Transfer-Encoding: quoted-printable
>
> Hello,
>
> It sounds like you want name-based virtual hosts. See
> http://httpd.apache.org/docs/2.2/vhosts/name-based.html
>
> Peter

For several years now I've been using virtualmin for just this  
situation, a lovely and largely automated management tool. Available  
with full function as GPL code and with extra bits in the for pay  
VM-Pro version.

Dave

>
> On Tue, Jul 19, 2011 at 07:20:15AM +1200, Peter B wrote:
>>
>> I have a single IP address, with multiple web servers, so I somehow  
>> need www.hello.com to go to server1 and www.test.com to go to  
>> server2.
>>
>> I know I can do this with NAT, but having to have people type  
>> www.hello.com:81 and www.test.com:82 is ugly, so is there a way  
>> apache can do this for me?
>
> --
> Openstrike - improving business through open source
> http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107
>



-- 
"It is no measure of health to be well adjusted to a profoundly sick society."
   Krishnamurti


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Virtual Hosts on physical servers

Posted by Pete Houston <ph...@openstrike.co.uk>.
Hello,

It sounds like you want name-based virtual hosts. See
http://httpd.apache.org/docs/2.2/vhosts/name-based.html

Pete

On Tue, Jul 19, 2011 at 07:20:15AM +1200, Peter B wrote:
> 
> I have a single IP address, with multiple web servers, so I somehow need www.hello.com to go to server1 and www.test.com to go to server2.
> 
> I know I can do this with NAT, but having to have people type www.hello.com:81 and www.test.com:82 is ugly, so is there a way apache can do this for me?

-- 
Openstrike - improving business through open source
http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107

Re: [users@httpd] Virtual Hosts on physical servers

Posted by Patrick Proniewski <pa...@univ-lyon2.fr>.
On 18 juil. 2011, at 23:25, Peter B wrote:

> Thank you Patrick, that does make sense, I'll do some more reading up..
> 
> I'm actually starting to think it might just be easier to host all the sites on one server, although sooner or later I'm going to need to do this anyhow.

that's for sure. A single Apache server is easier to manage and configure that many. "Keep It Simple" is a good rule. Think about a security update: you would have to deploy it on every virtual box servers, instead of doing it only once. That's to be taken into account too.


>> From: patrick.proniewski@univ-lyon2.fr
>> Date: Mon, 18 Jul 2011 23:16:36 +0200
>> To: users@httpd.apache.org; jc_denton_1372@hotmail.com
>> Subject: Re: [users@httpd] Virtual Hosts on physical servers
>> 
>> Your proxy can be an Apache Server, with mod_proxy, setup to forward client requests for www.hello.com to server1, and www.test.com to server2. That's not an unusual setup. 


Patrick PRONIEWSKI
-- 
Administrateur Système - DSI - Université Lumière Lyon 2


RE: [users@httpd] Virtual Hosts on physical servers

Posted by Peter B <jc...@hotmail.com>.
Thank you Patrick, that does make sense, I'll do some more reading up..

I'm actually starting to think it might just be easier to host all the sites on one server, although sooner or later I'm going to need to do this anyhow.

> From: patrick.proniewski@univ-lyon2.fr
> Date: Mon, 18 Jul 2011 23:16:36 +0200
> To: users@httpd.apache.org; jc_denton_1372@hotmail.com
> Subject: Re: [users@httpd] Virtual Hosts on physical servers
> 
> Hi,
> 
> On 18 juil. 2011, at 21:20, Peter B wrote:
> 
> > I have a single IP address, with multiple web servers, so I somehow need www.hello.com to go to server1 and www.test.com to go to server2.
> 
> 
> As long as you have only one public IP address, you'll have to put a device (sofware or hardware) between your servers (private IP addresses), and the internet.
> That can be NAT, but the port issue is not very nice for clients. Or, that can be a proxy, who will act almost like a NAT, but on the application level.
> Your proxy can be an Apache Server, with mod_proxy, setup to forward client requests for www.hello.com to server1, and www.test.com to server2. That's not an unusual setup. 
> That could also be a Layer 7 switch, but it's very expensive, doing exactly the same job (somewhat easier to configure).
> 
> 
> Patrick PRONIEWSKI
> -- 
> Administrateur Système - DSI - Université Lumière Lyon 2
> 
 		 	   		  

Re: [users@httpd] Virtual Hosts on physical servers

Posted by Patrick Proniewski <pa...@univ-lyon2.fr>.
On 18 juil. 2011, at 23:26, Peter B wrote:

> Patrick, Do you know of any examples on how to configure this?

I'm going to take a look at my old config files, I've done that years ago, may be I've still some valuable pointers.


>> From: patrick.proniewski@univ-lyon2.fr
>> Date: Mon, 18 Jul 2011 23:16:36 +0200
>> To: users@httpd.apache.org; jc_denton_1372@hotmail.com
>> Subject: Re: [users@httpd] Virtual Hosts on physical servers
>> 
>> Your proxy can be an Apache Server, with mod_proxy, setup to forward client requests for www.hello.com to server1, and www.test.com to server2. That's not an unusual setup. 


Patrick PRONIEWSKI
-- 
Administrateur Système - DSI - Université Lumière Lyon 2


Re: [users@httpd] Virtual Hosts on physical servers

Posted by Patrick Proniewski <pa...@univ-lyon2.fr>.
On 19 juil. 2011, at 07:36, Patrick Proniewski wrote:

>> Patrick, Do you know of any examples on how to configure this?
> 
> I'm going to take a look at my old config files, I've done that years ago, may be I've still some valuable pointers.


I was not able to find my old config files (10 years old...), but the setup should be: 

proxy server:
- holds the public IP
- runs Apache with mod_proxy
- uses named virtual hosting to define www.example1.com, www.example2.com, ...
- each vhost uses mod_proxy to forward request to server1, server2, ...

The config should look like something like this:

<VirtualHost *>
	ServerName example1.com
	ServerAlias www.example1.com
	<IfModule proxy_module>
	   ProxyRequests Off
	   <Proxy *> 
	      Order deny,allow
	      Allow from all
	   </Proxy> 
	   ProxyPass / http://PRIVATE-IP-FOR-SERVER1
	   ProxyPassReverse / http://PRIVATE-IP-FOR-SERVER1
	</IfModule>
</VirtualHost>

<VirtualHost *>
	ServerName example2.com
	ServerAlias www.example2.com
	<IfModule proxy_module>
	   ProxyRequests Off
	   <Proxy *> 
	      Order deny,allow
	      Allow from all
	   </Proxy> 
	   ProxyPass / http://PRIVATE-IP-FOR-SERVER2
	   ProxyPassReverse / http://PRIVATE-IP-FOR-SERVER2
	</IfModule>
</VirtualHost>

and so on. Be careful, this config is not tested, I'm pretty sure required directives are missing. And you should definitively add good logging directives, because the proxy won't transmit the client IP to the final server.

server1, server2, ...:
- holds a private IP address
- runs Apache
- uses named virtual hosting to define *one* of www.example1.com, www.example2.com... as the default vhost

If you want more than one vhost per server, you'll need to add "ProxyPreserveHost On" to the proxy configuration.

Patrick PRONIEWSKI
-- 
Administrateur Système - DSI - Université Lumière Lyon 2


RE: [users@httpd] Virtual Hosts on physical servers

Posted by Peter B <jc...@hotmail.com>.
Patrick, Do you know of any examples on how to configure this?

> From: patrick.proniewski@univ-lyon2.fr
> Date: Mon, 18 Jul 2011 23:16:36 +0200
> To: users@httpd.apache.org; jc_denton_1372@hotmail.com
> Subject: Re: [users@httpd] Virtual Hosts on physical servers
> 
> Hi,
> 
> On 18 juil. 2011, at 21:20, Peter B wrote:
> 
> > I have a single IP address, with multiple web servers, so I somehow need www.hello.com to go to server1 and www.test.com to go to server2.
> 
> 
> As long as you have only one public IP address, you'll have to put a device (sofware or hardware) between your servers (private IP addresses), and the internet.
> That can be NAT, but the port issue is not very nice for clients. Or, that can be a proxy, who will act almost like a NAT, but on the application level.
> Your proxy can be an Apache Server, with mod_proxy, setup to forward client requests for www.hello.com to server1, and www.test.com to server2. That's not an unusual setup. 
> That could also be a Layer 7 switch, but it's very expensive, doing exactly the same job (somewhat easier to configure).
> 
> 
> Patrick PRONIEWSKI
> -- 
> Administrateur Système - DSI - Université Lumière Lyon 2
> 
 		 	   		  

Re: [users@httpd] Virtual Hosts on physical servers

Posted by Patrick Proniewski <pa...@univ-lyon2.fr>.
Hi,

On 18 juil. 2011, at 21:20, Peter B wrote:

> I have a single IP address, with multiple web servers, so I somehow need www.hello.com to go to server1 and www.test.com to go to server2.


As long as you have only one public IP address, you'll have to put a device (sofware or hardware) between your servers (private IP addresses), and the internet.
That can be NAT, but the port issue is not very nice for clients. Or, that can be a proxy, who will act almost like a NAT, but on the application level.
Your proxy can be an Apache Server, with mod_proxy, setup to forward client requests for www.hello.com to server1, and www.test.com to server2. That's not an unusual setup. 
That could also be a Layer 7 switch, but it's very expensive, doing exactly the same job (somewhat easier to configure).


Patrick PRONIEWSKI
-- 
Administrateur Système - DSI - Université Lumière Lyon 2