Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You use correct syntax

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

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

share|improve this answer
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 at 23:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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