perhaps I can explain better with code.<br><br>on the php side its like this<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $memcache = new Memcache;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!$memcache-&gt;connect(&quot;192.168.0.9&quot;, 11211) ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //$host is HTTP_HOST variable.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $lock_key=$host.&quot;.lock&quot;;<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($memcache-&gt;get($host)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $memcache-&gt;increment($host);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $memcache-&gt;set($host, 1, false, 60); # calculate how many requests per minute, expire after 60seconds<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $x=$memcache-&gt;get($host);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($x&gt;100) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $memcache-&gt;set($lock_key, 1, false, 60); # lock the domain for 60 seconds<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>on nginx side i would like<br><br>if memcache get($http_host . lock){<br>&nbsp; redirect to another page<br>}<br><br><br>best regards<br><br><br><br><br><br><br><div class="gmail_quote">On Wed, Feb 4, 2009 at 1:11 AM, Atif Ghaffar <span dir="ltr">&lt;<a href="mailto:atif.ghaffar@gmail.com">atif.ghaffar@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Dear all,<br><br>A day ago, we had a DDOS attack.<br><br>To remedy that we have put some logic on the php application to check number of access on php per minute and if certain limit is matched do something like &quot;print &#39;please try later&#39; and exit&quot;<br>

<br>On the php side it will work fine but on the nginx side, it will still forward all the request to the php-cgi to get that response.<br><br>What I would like to do in php side is something like<br><br>if limit reached,<br>

key=hostname.locked, &quot;Please try again later&quot;<br><br>on nginx side.<br><br>If found memcached HTTP_HOST.locked, return someother file.<br><br>is that do-able.<br><br>best regards<br><br>
</blockquote></div><br><br clear="all"><br>-- <br>best regards<br>Atif Ghaffar<br>