httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Neil A. Hillard" <hilla...@whl.co.uk>
Subject Re: [users@httpd] (again) Can not define "default" name virtual host
Date Tue, 27 Jun 2006 13:31:33 GMT
Hi,

Matus UHLAR - fantomas wrote:
> On 27.06.06 13:30, Neil A. Hillard wrote:
>> I don't understand what the problem is here.  I've tested the
>> configuration suggested and it works fine (OK, I had to change the IP
>> address to match my setup):
>>
>> <VirtualHost 195.168.3.66:80>
>>  ServerName 195.168.3.66
>>  DocumentRoot /home/webs/195.168.3.66
>> </VirtualHost>
>>
>> <VirtualHost 195.168.3.66:80>
>>  ServerName default.fantomas.sk
>>  DocumentRoot /home/webs/default.fantomas.sk
>> </VirtualHost>
> 
> The problem is, that "default.fantomas.sk" does not exist:
> 
> Host default.fantomas.sk not found: 3(NXDOMAIN)
> 
> It has to be default name virtual host on this IP - the catch-all for all
> hosts not defined not listed in config file (e.g. nosuchserver.fantomas.sk
> or nosuchserver.apache.org):
> 
> 1151413212 default.fantomas.sk nosuchserver.fantomas.sk - nosuchserver.fantomas.sk 195.168.3.66
fantomas.fantomas.sk 200 20 5 - "/" "-" "-"
> 1151413489 default.fantomas.sk nosuchserver.apache.org - nosuchserver.apache.org 195.168.3.66
fantomas.fantomas.sk 200 20 4 - "/" "-" "-"
> 
> this is the log format:
> %{%s}t %v %V %{Host}o %{Host}i %a %h %>s %b %T %u \"%U\" \"%{Referer}i\" \"%{User-Agent}i\""
> 
> The reply has to be like "No server is configured at this address", while
> reply for "195.168.3.66" should be the std. page I configured.
> The problem currently is, request for 195.168.3.66 falls here :(
> 
>> You have made sure you've got a NameVirtualHost 195.168.3.66:80 set?
> 
> Yes.
> 
>> When not supplying a 'Host:' header or supplying the IP address in the
>> 'Host:' header then Apache responds using the first virtual server but
>> if the name 'default.fantomas.sk' is used then the second one is used.
> 
> Yes.
> 
> But nobody should request "default.fantomas.sk" (except me and other people
> looking at this problem). People may put 195.168.3.66 into their browser and
> get to virtual host for 195.168.3.66 - I make this server for people unable
> to use DNS resolution.
> 
> But if anybody points any hostname to 195.168.3.66, it should go to
> "default.fantomas.sk" (actually I can use any other name except
> fantomas.fantomas.sk/195.168.3.66) and tell people "go away, the server you
> asked for does not exist".
> 
> The pages you pointed me at (and also their 1.3 equivalent) say:
> 
> <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.

No, the VirtualHost entry tells Apache _where to listen_ for the request
and nothing else.  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.

You are trying to do something that Apache is not designed for.  You want:

195.168.3.66         -> /home/webs/195.168.3.66
fantomas.fantomas.sk -> /home/webs/fantomas.fantomas.sk
<everything else>    -> /home/webs/default.fantomas.sk

You can't do that.  You can do:

fantomas.fantomas.sk -> /home/webs/fantomas.fantomas.sk
<everything else>    -> /home/webs/default.fantomas.sk

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

This is not a bug but the way it works.  Now I'm pretty sure you could
use mod_rewrite to work around this but you're on your own for that.



				Neil.

-- 
Neil Hillard                    hillardn@whl.co.uk
Westland Helicopters Ltd.       http://www.whl.co.uk/

Disclaimer: This message does not necessarily reflect the
            views of Westland Helicopters Ltd.

---------------------------------------------------------------------
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


Mime
View raw message