# Access log off nginx not working?

**URL:** <https://www.ruby-forum.com/t/access-log-off-nginx-not-working/221286>\
**Category:** NGINX\
**Created:** [July 7, 2012, 1:46am UTC](https://www.ruby-forum.com/t/access-log-off-nginx-not-working/221286 "2012-07-07T01:46:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [July 7, 2012, 1:46am UTC](https://www.ruby-forum.com/t/access-log-off-nginx-not-working/221286/1 "2012-07-07T01:46:11Z")

</div>

I have the following drop.conf files located in /etc/nginx/drop.conf

location = /favicon.ico { access\_log off; log\_not\_found off; }  
location = /robots.txt { allow all; access\_log off; log\_not\_found off;  
}  
location = /apple-touch-icon.png { access\_log off; log\_not\_found off; }  
location = /apple-touch-icon-precomposed.png { access\_log off;  
log\_not\_found off; }  
location ~ /. { deny all; access\_log off; log\_not\_found off; }  
location ~\* ^/wp-content/uploads/._.php$ {  
deny all;  
access\_log off;  
log\_not\_found off;  
}  
location ~_ /files/(.\*).php$ {  
deny all;  
access\_log off;  
log\_not\_found off;  
}

Strange thing is when I include it in whichever server directive - ie in  
whichever virtual host I have configured - I’m still getting favicon  
logs in my access log. Is this a BUG ??  
It looks like the include is simply not working ?

Example of the virtual host I’m including this in:

server {  
listen 127.0.0.1:8080;  
server\_name .somehost.com;  
root /var/www/somehost.com;

```
    access_log /var/log/nginx/somehost.com-access.nginx.log main;
error_log /var/log/nginx/somehost.com-error.nginx.log;

    location ~* \.php.$ {
    # Proxy all requests with an URI ending with .php*
    # (includes PHP, PHP3, PHP4, PHP5...)
    include /etc/nginx/fastcgi.conf;
    }

    # all other files
    location / {
        root /var/www/somehost.com;
    }

    error_page 404 /errors/404.html;
    location /errors/ {
            alias /var/www/errors/;
            internal;
    }

    #this loads custom logging configuration which disables favicon

```

error logging  
include /etc/nginx/drop.conf;  
}

yet in access logs for that domain im still seeing:

\*\*\*\*\* - - [06/Jul/2012:22:16:05 +0000] “GET /favicon.ico HTTP/1.1” 404  
134 “-” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10\_7\_4)  
AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47  
Safari/536.11”  
Yes I have restarted and reloaded nginx.

When I add a specific location directive directly to the virtual host  
above and disable the include by commenting it in, favicon.ico requests  
ARE STILL being logged. ie. I comment in include bit and add the  
following to the above virtual host:

#include /etc/nginx/drop.conf;  
location = /favicon.ico { access\_log off; log\_not\_found off; }

Am I missing out something really obvious ? Or is this is a BUG ?  
Cheers

Posted at Nginx Forum:

> **[access log off nginx not working ?](https://forum.nginx.org/read.php?2,228344,228344#msg-228344)**
>
> I have the following drop.conf files located in /etc/nginx/drop.conf location = /favicon.ico { access\_log off; log\_not\_found off; } location = /robots.txt { allow all; access\_log off; log\_not\_found off; } location = /apple-touch-icon.png { access\_log...

---

<div class="post-metadata">

**Author:** ![gyre007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecccb3/32.png) [@gyre007](https://www.ruby-forum.com/u/gyre007)\
**Post date:** [July 7, 2012, 9:24am UTC](https://www.ruby-forum.com/t/access-log-off-nginx-not-working/221286/2 "2012-07-07T09:24:16Z")

</div>

Hello!

On Fri, Jul 06, 2012 at 07:45:29PM -0400, gyre007 wrote:

> I have the following drop.conf files located in /etc/nginx/drop.conf
> 
> location = /favicon.ico { access\_log off; log\_not\_found off; }

[…]

> Strange thing is when I include it in whichever server directive - ie in  
> whichever virtual host I have configured - I’m still getting favicon  
> logs in my access log. Is this a BUG ??  
> It looks like the include is simply not working ?
> 
> Example of the virtual host I’m including this in:
> 
> server {

[…]

> ```
> error_page 404 /errors/404.html;
> location /errors/ {
> alias /var/www/errors/;
> internal;
> }
> 
> ```

[…]

> \*\*\*\*\* - - [06/Jul/2012:22:16:05 +0000] “GET /favicon.ico HTTP/1.1” 404  
> 134 “-” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10\_7\_4)  
> AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47  
> Safari/536.11”

[…]

> Am I missing out something really obvious ?

Requests are logged in context of a location where request  
execution ends up. As you have error\_page 404 defined, and no  
favicon.ico file - error 404 is generated and redirected to  
/errors/404.html. As a result request is logged in context of  
“location /errors/” where you have access log enabled.

Maxim D.

---

<div class="post-metadata">

**Author:** ![gyre007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecccb3/32.png) [@gyre007](https://www.ruby-forum.com/u/gyre007)\
**Post date:** [July 7, 2012, 5:51pm UTC](https://www.ruby-forum.com/t/access-log-off-nginx-not-working/221286/3 "2012-07-07T17:51:56Z")

</div>

On Saturday 07 July 2012 17:52:52 gyre007 wrote:  
[…]

> The problem with this configuration is that the drop.conf file is  
> completely “ignored” because of what you said - so when I take  
> error\_page bit out then drop.conf file is suddenly taken into account  
> and favicon.ico is no longer being logged. The question is how do I  
> handle this situation → return 404 page when someone is accessing non  
> existing PHP URI and at the same time disable logging as per drop.conf  
> file ? Im banging my head against the table.  
> Any help appreciated.

error\_page 404 /errors/404.html;

location /errors/ {  
internal;  
root /var/www;  
}

location /errors/nolog/ {  
internal;  
alias /var/www/errors/;  
access\_log off;  
}

location = /favicon.ico {  
error\_page 404 /errors/nolog/404.html;  
log\_not\_found off;  
}

etc…

wbr, Valentin V. Bartenev

---

<div class="post-metadata">

**Author:** ![gyre007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecccb3/32.png) [@gyre007](https://www.ruby-forum.com/u/gyre007)\
**Post date:** [July 12, 2012, 3:09pm UTC](https://www.ruby-forum.com/t/access-log-off-nginx-not-working/221286/4 "2012-07-12T15:09:19Z")

</div>

On Sat, Jul 07, 2012 at 11:23:32AM +0400, Maxim D. wrote:

> > logs in my access log. Is this a BUG ??  
> > alias /var/www/errors/;  
> > […]
> 
> > Am I missing out something really obvious ?
> 
> Requests are logged in context of a location where request  
> execution ends up. As you have error\_page 404 defined, and no  
> favicon.ico file - error 404 is generated and redirected to  
> /errors/404.html. As a result request is logged in context of  
> “location /errors/” where you have access log enabled.

And BTW, this is documented here:

> **[Module ngx\_http\_log\_module](http://nginx.org/en/docs/http/ngx_http_log_module.html)**

---

<div class="post-metadata">

**Author:** ![gyre007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecccb3/32.png) [@gyre007](https://www.ruby-forum.com/u/gyre007)\
**Post date:** [July 7, 2012, 3:53pm UTC](https://www.ruby-forum.com/t/access-log-off-nginx-not-working/221286/5 "2012-07-07T15:53:19Z")

</div>

Hi Max,

> Maxim D.

thanks for the explanation - that was my initial thought too but as I’m  
rookie I wasn’t sure. Thanks again.  
In that case I’m hitting a wall while trying to figure out how to  
configure my server for the following scenario.  
I have fastcgi\_intercept\_errors set in http block and have put  
error\_pages directive in the virtual host definition above to handle the  
cases when someone tries to access PHP URI which does not exist – if I  
take it away then Im getting “no input file specified” – which I  
know makes sense as PHP-FPM is not able to find given file and reports  
back to browser.

The problem with this configuration is that the drop.conf file is  
completely “ignored” because of what you said - so when I take  
error\_page bit out then drop.conf file is suddenly taken into account  
and favicon.ico is no longer being logged. The question is how do I  
handle this situation → return 404 page when someone is accessing non  
existing PHP URI and at the same time disable logging as per drop.conf  
file ? Im banging my head against the table.  
Any help appreciated.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,228344,228359#msg-228359](http://forum.nginx.org/read.php?2,228344,228359#msg-228359)
