You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "HARADA,LIZA (HP-Cupertino,ex1)" <li...@hp.com> on 2001/12/12 19:16:57 UTC

Virutal Host and ServerName with ports...

Hello there,

I am trying to understand the VirtualHost directives for Apache 2.0,
specifically with regards to specifying the port. With ServerName directive
now able to specify ports, it brings another element into the picture. Does
it make a difference if the port is specified in the <VirtualHost
my.ip.addr.here:port> or in the ServerName my.domain.here:port ? What about
if there are multiple ip addresses/ports specified in the Virtual Host? How
does that affect the ServerName? Is it best to specify the multiple ports/ip
in the VirtualHost directive and then leave the ServerName with only the
domain.name and no port?
I hope this makes sense. 

Here is an example :
	    ...
	    Listen 1.2.3.4:80
	    Listen 1.2.3.5:8080
	    ServerName server.domain.com
	    
	    <VirtualHost 1.2.3.4:80>    #VHOST 1
	    DocumentRoot /www/domain
	    ServerName www.domain.com
	    ...
	    </VirtualHost>

	    <VirtualHost 1.2.3.5:8080>  # VHOST 2
	    ServerName other.domain.com
	    ...
	    </VirtualHost>

Can VHOST 1 be specified instead: 
	    <VirtualHost 1.2.3.4>    #VHOST 1
	    DocumentRoot /www/domain
	    ServerName www.domain.com:80
	    ...
	    </VirtualHost>

or would it be legal to do this?: 
	    <VirtualHost 1.2.3.4:80 1.2.3.5:8080>    #VHOST 1 
	    DocumentRoot /www/domain                  
	    ServerName www.domain.com:??           #maybe no port specified?
	    ...
	    </VirtualHost>

Thanks in advance,
Liza


Re: Virutal Host and ServerName with ports...

Posted by Ryan Bloom <rb...@covalent.net>.
On Tuesday 18 December 2001 03:35 am, jean-frederic clere wrote:
> Ryan Bloom wrote:
> > 
> > Hi.
> > 
> > The big thing about ServerName in 2.0 is that it has taken over for the Port
> > directive from 1.3. So, the following config means that the server
> > listens on 127.0.0.1, port 8080, but reports itself as foo.com on port 80.
> > 
> > <VirtualHost 127.0.0.1:8080>
> >     ServerName foo.com:80
> > </VirtualHost>
> > 
> > That reporting is done whenever the server creates a self-referential
> > URL, which is done by mod_dir, and in all error pages among other
> > places in the code.
> > 
> > The ServerName directive NEVER controls the port that the server
> > actuall listens on.
> 
> Hi,
> 
> That brings a small problem in mod_webapp:
> The ServerName hostname:port is used to build the virtual host for Tomcat.
> A redirect from Tomcat will come for hostname:port...
> This fails if the port is not the one used for the listen...
> 
> Any hints to solve this?

The temporary fix is to use UseCanonicalName off.

Ryan
______________________________________________________________
Ryan Bloom				rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------

Re: Virutal Host and ServerName with ports...

Posted by Pier Fumagalli <pi...@betaversion.org>.
jean-frederic clere <jf...@fujitsu-siemens.com> wrote:

> Ryan Bloom wrote:
>> 
>> Hi.
>> 
>> The big thing about ServerName in 2.0 is that it has taken over for the Port
>> directive from 1.3. So, the following config means that the server
>> listens on 127.0.0.1, port 8080, but reports itself as foo.com on port 80.
>> 
>> <VirtualHost 127.0.0.1:8080>
>>     ServerName foo.com:80
>> </VirtualHost>
>> 
>> That reporting is done whenever the server creates a self-referential
>> URL, which is done by mod_dir, and in all error pages among other
>> places in the code.
>> 
>> The ServerName directive NEVER controls the port that the server
>> actuall listens on.
> 
> Hi,
> 
> That brings a small problem in mod_webapp:
> The ServerName hostname:port is used to build the virtual host for Tomcat.
> A redirect from Tomcat will come for hostname:port...
> This fails if the port is not the one used for the listen...
> 
> Any hints to solve this?

This whole thing is _screwed_ in Tomcat... I posted a couple of months ago
about it on the list, but apparently noone wants to fix it (or "it fucked
but it works for them")... Bah... I'm tired...

    Pier


Re: Virutal Host and ServerName with ports...

Posted by jean-frederic clere <jf...@fujitsu-siemens.com>.
Ryan Bloom wrote:
> 
> Hi.
> 
> The big thing about ServerName in 2.0 is that it has taken over for the Port
> directive from 1.3. So, the following config means that the server
> listens on 127.0.0.1, port 8080, but reports itself as foo.com on port 80.
> 
> <VirtualHost 127.0.0.1:8080>
>     ServerName foo.com:80
> </VirtualHost>
> 
> That reporting is done whenever the server creates a self-referential
> URL, which is done by mod_dir, and in all error pages among other
> places in the code.
> 
> The ServerName directive NEVER controls the port that the server
> actuall listens on.

Hi,

That brings a small problem in mod_webapp:
The ServerName hostname:port is used to build the virtual host for Tomcat.
A redirect from Tomcat will come for hostname:port...
This fails if the port is not the one used for the listen...

Any hints to solve this?

Cheers

Jean-frederic

> 
> Ryan
> 
> On Wednesday 12 December 2001 10:16 am, HARADA,LIZA (HP-Cupertino,ex1) wrote:
> > Hello there,
> >
> > I am trying to understand the VirtualHost directives for Apache 2.0,
> > specifically with regards to specifying the port. With ServerName directive
> > now able to specify ports, it brings another element into the picture. Does
> > it make a difference if the port is specified in the <VirtualHost
> > my.ip.addr.here:port> or in the ServerName my.domain.here:port ? What about
> > if there are multiple ip addresses/ports specified in the Virtual Host? How
> > does that affect the ServerName? Is it best to specify the multiple
> > ports/ip in the VirtualHost directive and then leave the ServerName with
> > only the domain.name and no port?
> > I hope this makes sense.
> >
> > Here is an example :
> >           ...
> >           Listen 1.2.3.4:80
> >           Listen 1.2.3.5:8080
> >           ServerName server.domain.com
> >
> >           <VirtualHost 1.2.3.4:80>    #VHOST 1
> >           DocumentRoot /www/domain
> >           ServerName www.domain.com
> >           ...
> >           </VirtualHost>
> >
> >           <VirtualHost 1.2.3.5:8080>  # VHOST 2
> >           ServerName other.domain.com
> >           ...
> >           </VirtualHost>
> >
> > Can VHOST 1 be specified instead:
> >           <VirtualHost 1.2.3.4>    #VHOST 1
> >           DocumentRoot /www/domain
> >           ServerName www.domain.com:80
> >           ...
> >           </VirtualHost>
> >
> > or would it be legal to do this?:
> >           <VirtualHost 1.2.3.4:80 1.2.3.5:8080>    #VHOST 1
> >           DocumentRoot /www/domain
> >           ServerName www.domain.com:??           #maybe no port specified?
> >           ...
> >           </VirtualHost>
> >
> > Thanks in advance,
> > Liza
> 
> --
> 
> ______________________________________________________________
> Ryan Bloom                              rbb@apache.org
> Covalent Technologies                   rbb@covalent.net
> --------------------------------------------------------------

Re: Virutal Host and ServerName with ports...

Posted by Ryan Bloom <rb...@covalent.net>.
Hi.

The big thing about ServerName in 2.0 is that it has taken over for the Port
directive from 1.3. So, the following config means that the server
listens on 127.0.0.1, port 8080, but reports itself as foo.com on port 80.

<VirtualHost 127.0.0.1:8080>
    ServerName foo.com:80
</VirtualHost>

That reporting is done whenever the server creates a self-referential
URL, which is done by mod_dir, and in all error pages among other
places in the code.

The ServerName directive NEVER controls the port that the server 
actuall listens on.

Ryan

On Wednesday 12 December 2001 10:16 am, HARADA,LIZA (HP-Cupertino,ex1) wrote:
> Hello there,
>
> I am trying to understand the VirtualHost directives for Apache 2.0,
> specifically with regards to specifying the port. With ServerName directive
> now able to specify ports, it brings another element into the picture. Does
> it make a difference if the port is specified in the <VirtualHost
> my.ip.addr.here:port> or in the ServerName my.domain.here:port ? What about
> if there are multiple ip addresses/ports specified in the Virtual Host? How
> does that affect the ServerName? Is it best to specify the multiple
> ports/ip in the VirtualHost directive and then leave the ServerName with
> only the domain.name and no port?
> I hope this makes sense.
>
> Here is an example :
> 	    ...
> 	    Listen 1.2.3.4:80
> 	    Listen 1.2.3.5:8080
> 	    ServerName server.domain.com
>
> 	    <VirtualHost 1.2.3.4:80>    #VHOST 1
> 	    DocumentRoot /www/domain
> 	    ServerName www.domain.com
> 	    ...
> 	    </VirtualHost>
>
> 	    <VirtualHost 1.2.3.5:8080>  # VHOST 2
> 	    ServerName other.domain.com
> 	    ...
> 	    </VirtualHost>
>
> Can VHOST 1 be specified instead:
> 	    <VirtualHost 1.2.3.4>    #VHOST 1
> 	    DocumentRoot /www/domain
> 	    ServerName www.domain.com:80
> 	    ...
> 	    </VirtualHost>
>
> or would it be legal to do this?:
> 	    <VirtualHost 1.2.3.4:80 1.2.3.5:8080>    #VHOST 1
> 	    DocumentRoot /www/domain
> 	    ServerName www.domain.com:??           #maybe no port specified?
> 	    ...
> 	    </VirtualHost>
>
> Thanks in advance,
> Liza

-- 

______________________________________________________________
Ryan Bloom				rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------