Empty server name argument - Can't get it to work

Igor Sysoev is at rambler-co.ru
Thu Aug 28 12:57:18 MSD 2008


On Thu, Aug 28, 2008 at 08:36:19AM +0000, Luigi Perroti wrote:

> I'm trying out the new 0.7.13 release which permits to use "" as server name,
> but there must be something wrong with my configuration since I can't get this
> new feature to work.
> 
> Here's the relevant snippet from my configuration file:
> 
> http {
>   access_log off;
>   recursive_error_pages off;
>   server {
>     listen 123.123.123.123:80;
>     server_name _ "";
>     error_page 400 /400.html;
>     location /400.html {
>       internal;
>       if ($host = "") {
>         access_log /var/log/access.log;
>       }
>     }
>     location / {
>       fastcgi_pass   127.0.0.1:1234;
>       fastcgi_intercept_errors on;
>     }
>   }	
> }
> 
> I thought that with this configuration I'd be able to:
> - have the application behind the fastcgi server receive requests with no Host:
> header specified.
> - log into access.log when my custom 400 error page is served, but only if no
> Host: header is present.
> 
> Instead the behaviour I'm observing is that when nginx receives a request
> without the Host: header my custom 400 page gets served without sending the
> request to the fastcgi server and nothing is logged into access.log either.

$host is this case is "_", server_name. You should use $http_host.


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list