access_log off

Maxim Dounin mdounin at mdounin.ru
Wed Sep 5 15:32:27 MSD 2007


Hello!

On Wed, 5 Sep 2007, Jose Manuel Gonzalez Calvar wrote:

> I'd like to desactivate all logs for a directory in my web, the problem is
> that this is dinamic and fastcgi is  who serves it.
> I try to insert the second location like:
>
> location /home {
>   root /var/www/html/myweb.com/home;
>   index index.htm;
>   access_log off;
>
> }
>
> But when I watch the log I see requests to home/. I'd like not  writing it.
>
> My example configuration with the location I try to insert:
>
> access_log  /var/log/nginx/access.log  main;
>
>         location  / {
>            root   /var/www/html/myweb.com;
>            index  index.html index.htm;
>        }
>
>
> location ~ \.php$|\.htm$ {
>            #fastcgi_pass   localhost:10005;
>            fastcgi_pass   unix:/tmp/nginx-fcgi;
>            fastcgi_index  index.htm;
>            fastcgi_param  SCRIPT_FILENAME
> /var/www/html/myweb.com$fastcgi_script_name;
>            fastcgi_intercept_errors on;
>            #include        /usr/local/nginx/conf/fastcgi.conf;
>        }
>
> location ~* ^.+\.(jpg|jpeg|gif|png|css|js)$ {
>                root         /var/www/html/myweb.com;
>                access_log   off;
>                expires      30d;
>       }
>
> Does anybody if I can do it?

Looks like your problem is that request served by one of regex locations 
in your config, not the location /home {}. So anything you specify in 
location /home {} doesn't matter.

To solve the problem you should rewrite your config like this:

location /home {
     access_log off;
     ...
}
location ~ ^/home.*\.php$|\.htm$ {
     access_log off;
     ...
}
location ~* ^/home.*\.(jpg|jpeg|gif|png|css|js)$ {
     access_log off;
     ...
}

And make sure home-specific regex locations written in config _before_ 
general ones.

Maxim Dounin





More information about the nginx mailing list