exception for NGINX limit_req_zone

fhal meteor8488 at 163.com
Sat Jul 21 02:26:23 UTC 2012


Hi Francis.

Thanks very much.
I tried to use map, but it doesn't work. Below is the settings.

    map $arg_mod $forum_limit {
        default  $binary_remote_addr;
        image    '';
        }
    limit_conn_zone  $forum_limit  zone=addr:128m;
    limit_req_zone  $forum_limit  zone=refresh:128m   rate=3r/s;

server {
    location ~*^/(home|forum|portal).php$ {
        root           /web/www;
        limit_conn   addr  5;
        limit_req zone=refresh burst=5 nodelay;
        fastcgi_pass   unix:/tmp/nginx.socket;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
        }
    location ~ \.php$ {
        root           /web/www;
        fastcgi_pass   unix:/tmp/nginx.socket;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
        }
    }





At 2012-07-21 06:38:49,"Francis Daly" <francis at daoine.org> wrote:
>On Fri, Jul 20, 2012 at 09:48:04PM +0800, fhal wrote:
>
>Hi there,
>
>> I got a problem with NGINX limit_req_zone. Anyone can help? The problem is that, I want to limit user access to some specific URL, for example:
>> 
>> /forum.php?mod=forumdisplay?
>> /forum.php?mod=viewthread&***
>> 
>> But, I do want to add an exception for below URL,
>> 
>> /forum.php?mod=image&*
>
>For nginx "location" matches, these three are all the same, and are all
>exactly "/forum.php". The "location" goes from the first / to just before
>the first ? or #.
>
>That is why your configuration is not doing what you want.
>
>> location ~*^/(home|forum|portal).php$ {
>>     root           /web/www;
>>     limit_conn   addr  5;
>>     limit_req zone=refresh burst=5 nodelay;
>>     fastcgi_pass   unix:/tmp/nginx.socket;
>>     fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
>>     include        fastcgi_params;
>>     }
>
>I do not know what the solution is, but I expect it will involve doing
>something different based on the value of $arg_mod, within that location
>block.
>
>How is limit_req_zone zone=refresh defined? Would using "map" to set
>the relevant $variable to empty if $arg_mod is "image" be appropriate?
>
>Good luck with it,
>
>	f
>-- 
>Francis Daly        francis at daoine.org
>
>_______________________________________________
>nginx mailing list
>nginx at nginx.org
>http://mailman.nginx.org/mailman/listinfo/nginx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120721/eca4e3c6/attachment.html>


More information about the nginx mailing list