2

I'm trying to don't log requests made from a specific ip address like this:

location = / {
    index index.php;
    if ( $remote_addr = "spe.ci.fic.ip" )
    {
        access_log off;
    }

}

But it doesn't work, why?

6

You use correct syntax

location ~ ^/(css|js) {
    if ( $remote_addr = "127.0.0.1" ) 
    {
        access_log off;
    }
}

In your example nginx doesn't write logs only for '/' location.

  • I doesn't work for me :/ – GlinesMome Mar 17 '13 at 15:55
  • I tested on nginx/1.3.6, works as expected. – Valery Viktorovsky Mar 17 '13 at 17:15
  • Initially it didn't work for me either, it works only if it matches the location. – Danail Gabenski Apr 14 '15 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.