help about limit_req

fhal meteor8488 at 163.com
Thu Jul 19 15:04:58 UTC 2012


Hi Reinis,

One more question, for now, I'm using below code to limit the access of some URLs, such as
/forum.php?mod=forumdisplay?*****
/forum.php?mod=viewthread&****

    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;
        }

But I don't want to limit user access to below URL

/forum.php?mod=image&***

So I added below section into Nginx

    location ~*^/forum.php?mod=image$ {
        root           /web/www;
        fastcgi_pass   unix:/tmp/nginx.socket;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
        }

But it seems that this rule is not working, could you please help?




At 2012-07-18 20:22:21,"Reinis Rozitis" <r at roze.lv> wrote:
>> For now, the problem for me is, if I put below codes in NGINX, then my php file will stop execute.
>
>A quick fix would be just nest the locations or duplicate the fastcgi part. For example:
>
>location ~*^/(home|forum|portal).php$ {
>          limit_conn   addr  3;
>          limit_req zone=refresh burst=3 nodelay;
>
>          fastcgi_pass   unix:/tmp/nginx.socket;
>          fastcgi_index  index.php;
>          fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
>          include        fastcgi_params;
>}
>
>
>rr
>
>_______________________________________________
>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/20120719/01b10808/attachment.html>


More information about the nginx mailing list