0

I use a map in nginx to block bad user agents (nutch and such). Some RSS readers have funny user agents, so I rather not run the map on that directory.

Stripping down the nginx.conf file:

server{
location / {
 root   /usr/share/nginx/html/mydomain/public_html;
        if ($badagent)     { return 403; }
}
location = /feeds {
        try_files $uri $uri.xml $uri/ ;
       }
}

The "=" should force an exact match, but the badagent map is checked.

  • Are you trying to not block /feeds , or any url that begins with /feeds ? like /feeds/hello ? – flaixman Jan 17 at 10:09
1
server{

    location ~ ^/feeds {
            try_files $uri $uri.xml $uri/ ;
    }


    location / {
     root   /usr/share/nginx/html/mydomain/public_html;
        if ($badagent)     { return 403; }
    }


}

What I think you want is anything under /feeds, not /feeds itself , location = /feeds only will match example.com/feeds , and location ~ ^/feeds will match anything beggining with /feeds*(example.com/feeds/facebook example.com/feeds/myspace . Hope I helped

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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