perhaps I can explain better with code.<br><br>on the php side its like this<br> $memcache = new Memcache;<br> if (!$memcache->connect("192.168.0.9", 11211) ) {<br> return;<br>
}<br> //$host is HTTP_HOST variable.<br><br> $lock_key=$host.".lock";<br><br><br> if ($memcache->get($host)) {<br> $memcache->increment($host);<br>
} else {<br> $memcache->set($host, 1, false, 60); # calculate how many requests per minute, expire after 60seconds<br> }<br> $x=$memcache->get($host);<br> if ($x>100) {<br>
$memcache->set($lock_key, 1, false, 60); # lock the domain for 60 seconds<br>
}<br><br>on nginx side i would like<br><br>if memcache get($http_host . lock){<br> 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"><<a href="mailto:atif.ghaffar@gmail.com">atif.ghaffar@gmail.com</a>></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 "print 'please try later' and exit"<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, "Please try again later"<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>