custom 404 error_page seems to conflict with access_log off

Maxim Dounin mdounin at mdounin.ru
Sun Feb 26 20:57:25 UTC 2012


Hello!

On Sun, Feb 26, 2012 at 08:43:07PM +0100, Grégory Pakosz wrote:

> Hello,
> 
> In my server block, I configured a custom 404 error page and I tried to
> disable access log for /favicon.ico
> 
> error_page 404 /404.html;
> location = /favicon.ico {
>   access_log off;
> }
> 
> http://pastebin.com/39qXWuq2
> 
> It seems that both conflicts.
> 
> When favicon.ico is present:
> curl -I http://mydomain.com/favicon.ico reports 200 status code and nothing
> gets logged into my access log
> 
> When favicon.ico is missing:
> curl -I http://mydomain.com/favicon.ico reports 404 status code
> curl http://mydomain.com/favicon.ico displays my custom 404 html page
> and strangely the 404 error gets logged into my access log: "HEAD
> /favicon.ico HTTP/1.1" 404 0 "-" "curl/7.19.7 (universal-apple-darwin10.0)
> libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3"
> 
> When I comment out #error_page 404 /404.html; when favicon.ico is missing:
> curl -I http://mydomain.com/favicon.ico reports 404 status code
> curl http://mydomain.com/favicon.ico displays nginx's default 404 page
> nothing gets logged into my access log
> 
> Can someone explain me this behavior?

Requests are logged in a context of a location where processing ends.

That is, if you have 404 error_page configured requests to a 
missing favicon.ico file are internally redirected to /404.html, 
and handled in an appropriate location, not in location = 
/favicon.ico where you have access_log switched off.

Maxim Dounin



More information about the nginx mailing list