httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Owen Boyle <...@bourse.ch>
Subject Re: Port-based Virtual Hosts
Date Tue, 15 Jan 2002 08:50:02 GMT
Darrel Austin wrote:
> 
> I had a question awhile back about getting two servers running behind
> one IP. After almost giving up (as it looked like I just can't) I was
> told offlist, to use the port-based virtual host configurations.
> 
> The documentation shows this:
> 
>      Listen 80
>      Listen 8080
>      ServerName www.domain.tld
>      DocumentRoot /www/domain
> 
>      <VirtualHost 111.22.33.44:8080>
>      DocumentRoot /www/domain2
>      ...
>      </VirtualHost>
> 
> This doesn't tell me if I can actually have two actual servers,
> however. Does the port-based VH have to be on the same machine as
> that is hosting the default port 80 traffic? Or can this port-based
> VH point at a seperate IP address + port behind the router? Is the
> above config text supposed to be on the main server (listening on
> port 80) or the other server (listening on port 8080)?
> 
> In attempting to enter the above on the main server, I get an error
> 'directory can not be found' for the VH on the other IP...leading me
> to believe that this, in fact, will not work.
> 
> If that doesn't work, is there anyway to point at the second server
> via a domain name or sub-domain name? At the very least, we'd like to
> be able to point to the domain at an external site and have an HTML
> redirect to this server (via a different port than the main
> server...for example, 'xyz.com' would redirect to 'xyz.abc.com:8080')
> but from what I can tell, we can probably only do a redirect if we
> explicitly spell out the IP+port. It's ugly, but it'd work, suppose.

I'm not too clear what you want to do. If you have the content of both
sites on the same physical machine and you want to do port based VH-ing,
then that is no problem. Note that in the config example you give, you
are using one iste as the "main" domain (outside a VH) and the other
inside a VH - this works but is confusing and difficult to maintain. A
better config, where everything is at the same level in a VH is:

      Listen 111.22.33.44:80
      <VirtualHost 111.22.33.44:80>
        ServerName www.domain.tld
        DocumentRoot /www/domain
      </VirtualHost>
 
      Listen 111.22.33.44:8080
      <VirtualHost 111.22.33.44:8080>
        DocumentRoot /www/domain2
      </VirtualHost>

The only snag with this approach is that the client has to specify port
8080 in the URL (and any FW between you and the client has to let it
through). You can do everything on port 80 if you use name-based VHs:

      NameVirtualHost 111.22.33.44
      Listen 111.22.33.44:80

      <VirtualHost 111.22.33.44:80>
        ServerName www.domain.tld
        DocumentRoot /www/domain
      </VirtualHost>

      <VirtualHost 111.22.33.44:80>
        ServerName www.domain2.tld
        DocumentRoot /www/domain2
      </VirtualHost>

This will serve the different sites depending on the "Host:" field in
the request (i.e. what the client types into the browser).

Note that in both cases, the two sites are running off the *same* server
- i.e. there is only one instance of apache running.

If you (for whatever reason) want to have *two* instances of apache,
then you need two separate config files, start apache twice and make
sure the IP/port allocations don't conflict, e.g.

config 1:

      Listen 111.22.33.44:80
      ServerName www.domain.tld
      DocumentRoot /www/domain

config 2:

      Listen 111.22.33.44:8080
      ServerName www.domain2.tld
      DocumentRoot /www/domain2

Since the two servers are distinct instances, you don't need VHs.
Functionally, this is the same as IP-base VHing but with the distinction
that you can stop one server without interrupting the other.

Not sure if this answers your question...

Rgds,

Owen Boyle.

---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message