Condition to match a missing "Host:" header

Igor Sysoev is at rambler-co.ru
Thu Aug 21 21:38:00 MSD 2008


On Thu, Aug 21, 2008 at 05:21:38PM +0000, Luigi Perroti wrote:

> Igor Sysoev <is at ...> writes:
> 
> >You need just:
> >
> >location = /400.html {
> >     root /www/errors;
> >     internal;
> >     access_log /var/log/nginx/access.log;
> >}
> 
> Unfortunately, if I do that the 400 responses that my application sends get
> logged too. Which I would prefer to avoid.
> 
> >BTW, in 0.7.12 the special server_name "" will allow to handle
> >requests without Host not in default listening server:
> >
> >     server {
> >         listen 80 default;
> >         server_name  _;
> >     }
> >
> >    server {
> >         listen 80;
> >         server_name  www.example.com "";
> >     }
> 
> Does that mean that if ($host = "") would evaluate to true if no Host: header is
> sent? That would precisely be what I need.

Yes.

Why at all do you want to log request without Host ?


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





More information about the nginx mailing list