<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial">Hi All,<br>In the pass several days my server was under attack.<br>Someone are using WebBench to test my website, and it takes up all my server CPU resources.<br>So I'm wondering to use  limit_req to limit the request frequency.<br><br>I have 3 important php files -- portal.php forum.php home.php, they are in the root directory of my website, the URL like below:<br>    http://www.xxx.com/forum.php<br>
    http://www.xxx.com/forum.php?******<br><br>And I also created below rules for URL rewrite in NGINX:<br>            rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;<br>            rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;<br>            rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;<br>            rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;<br>            rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;<br>  <br>For now, the problem for me is, if I put below codes in NGINX, then my php file will stop execute.<br><br>    location ~*^/(home|forum|portal).php$ {<br>              limit_conn   addr  3;<br>                limit_req zone=refresh burst=3 nodelay;<br>                    }<br><br> And if I put the limit (     limit_req zone=refresh burst=3 nodelay;) into below sections. It works, but user reports that sometimes they can't view the images.<br><br> location ~ \.php$ {<br>            fastcgi_pass   unix:/tmp/nginx.socket;<br>            fastcgi_index  index.php;<br>            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;<br>            include        fastcgi_params;<br>        }<br>    <br>    <br>    Anyone can help me about this issue? I just want to set a limit for some specific php files?<br><br></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>