Re: [users@httpd] (again) Can not define "default" name virtual host

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

 



On 6/27/06, Matus UHLAR - fantomas <uhlar@xxxxxxxxxxx> wrote:
> > <CITE>
> > Now when a request arrives, the server will first check if it is using an IP
> > address that matches the NameVirtualHost. If it is, then it will look at
> > each <VirtualHost> section with a matching IP address and try to find one
> >                                   ^^^^^^^^^^^^^^^^^^^
> > where the ServerName or ServerAlias matches the requested hostname. If it
> >           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > finds one, then it uses the configuration for that server. If no matching
> > virtual host is found, then the first listed virtual host that matches the
> > IP address will be used.
> > </CITE>
> >
> > They only say, that the requested host name should match ServerName and
> > ServerAlias. But, when the name provided in <VirtualHost> matches the name
> > requested, the virtual host matches too.

On 27.06.06 14:31, Neil A. Hillard wrote:
> No, the VirtualHost entry tells Apache _where to listen_ for the request
> and nothing else.

That is, what docs says and how I understand it.

> The VirtualHost must match the IP:port combination of the request
> in order for that virtual host to stand a chance of
> receiving the request.

by "the request" I understood the destination IP address and port where the
request came, independently on the Host: header.

by "host receiving the request" I understood the virtual host (on the given
IP) whose ServerName or ServerAlias match the provided Host: header. If none
VirtualHost matches, the first has to be used.

> end of story.  Apache doesn't do it and unless you write a patch then I
> suspect no one else will.

Then, can at least someone help me to write such patch?


I was curious as well as to *why* this is the way it is, so I looked
in the source...

This is intended for some reason or another.  In the source, the
<VirtualHost> name is searched first (in order of appearance in conf
file) and returns a match before ServerName/Alias is even tried.
There is even a comment in the source stating that "If this is a
NameVirtualHost then we may not be doing the Right Thing".  So you
could argue a bug, but this goes all the way through to 2.2.2 so it
will never be changed, heh.

So, as previously stated, just always configure your VH with
ServerName same as <VirtualHost> tag as the *first* one in the file.
This will work fine.

As for patching (not recommended), you could change
ap_matches_request_vhost in http_vhost.c to run the matches_aliases
before the VirtualHost name matches.  But, I think changing the order
of your conf would be easier.

-B

---------------------------------------------------------------------
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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-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