Re: Should name based virtual hosts work when the ServerName is an IP address?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--On 29 May 2012 16:02:25 +0200 Matus UHLAR - fantomas <uhlar@xxxxxxxxxxx> wrote:

This was documented feature in 1.3 and 2.0:

The complete list of names in the VirtualHost  directive are treated just
like a ServerAlias (but are not overridden by any ServerAlias statement)
if all names resolve to the same address set. Note that subsequent Listen
statements for this vhost will not affect the ports assigned in the
address set.

It seems that in 2.2 it should work as you expect. Do you still use 2.0
or does this problem apply in 2.2 too?
(I've checked now and seems it's gone in 2.2)

On 29.05.12 16:40, Alex Bligh wrote:
I am using 2.2 (latest from Ubuntu Lucid).

I am not sure how to parse your second paragraph. There is only one
Listen statement as this is a NameVirtualHost (in this case a Listen
for *:80). NameVirtualHost is on 192.200.0.1:80 because there are
non-namebased virtual hosts on other IP addresses.

it's not mine, but from apache 1.3/2.0 docs.
I think what you are saying is that in 1.3 and 2.0 the first declared
virtual host not only acts as the default virtual host but also as if
it had an alias defined for the IP address/port pair it is listening
on.

Not the on it's listening on, but the one in VirtualHost section.
It means than for

<VirtualHost some.na.me>

the some.na.me becomes a hidden alias of the virtualhost.
So, when you define

<VirtualHost 192.168.0.1>
</VirtualHost>
<VirtualHost 192.168.0.1>
ServerName 192.168.0.1
</VirtualHost>

the second won't apply for 192.168.0.1, because 192.168.0.1 is already alias (hidden) of the first (default) virtual host.

My understanding from the documentation is that this is not the
intended behaviour on 2.2 - i.e. each vhost should be responding only
for its defined ServerAlias and ServerName, and if none match the
default should be used. That does not /appear/ to be happening, so perhaps
the behaviour has not changed from the 1.3/2.0 behaviour you describe.

Is that meant to be the case?

If so, is there any way around this? (i.e. so an arbitrary DNS name pointing
to the IP address will get the default vhost, but the IP address itself
will get a different vhost).

I worked around this problem by defining fake name in NameVirtualHost and VirtualHost sections

# some.na.me maps to 192.168.0.1
NameVirtualHost some.na.me
NameVirtualHost 192.168.0.1

# some.na.me is not resolvable from outside, so this host will ONLY get # default hosts - unspecified below
<VirtualHost some.na.me>
ServerName some.na.me
</VirtualHost>

# This host will only process requests for 192.168.0.1
<VirtualHost 192.168.0.1>
ServerName 192.168.0.1
</VirtualHost>

--
Matus UHLAR - fantomas, uhlar@xxxxxxxxxxx ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Microsoft dick is soft to do no harm

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux