Need logic to not check for bad user agent if xml file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Need logic to not check for bad user agent if xml file

lists@lazygranch.com
I have a map to check for bad user agents called badagent. I want to
set up a RSS feed. The feedreaders can have funny agents, so I need to
omit the bad agent check if the file is any xml type.

This is rejected.

        if (($request_uri != [*.xml]) && ($badagent)) {return 444; }

Suggestions?

I can put the xml files in a separate location if that helps.
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Need logic to not check for bad user agent if xml file

Maxim Dounin
Hello!

On Thu, Dec 20, 2018 at 01:42:49AM -0800, [hidden email] wrote:

> I have a map to check for bad user agents called badagent. I want to
> set up a RSS feed. The feedreaders can have funny agents, so I need to
> omit the bad agent check if the file is any xml type.
>
> This is rejected.
>
>         if (($request_uri != [*.xml]) && ($badagent)) {return 444; }
>
> Suggestions?
>
> I can put the xml files in a separate location if that helps.

Doing the $badagent only in locations where you want to reject
bots would be the most simple approach.  That is, consider
something like this:

    location / {
        if ($badagent) {
            return 403;
        }

        ...
    }

    location /rss/ {
        ...
    }

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx