<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Winnipeg Linux Support and Consulting &#124; ONE ROOT &#187; nginx</title>
	<atom:link href="http://www.oneroot.ca/category/web-servers/nginx/feed" rel="self" type="application/rss+xml" />
	<link>http://www.oneroot.ca</link>
	<description>Linux Support and Consulting in Winnipeg</description>
	<lastBuildDate>Fri, 25 Sep 2009 03:26:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Struggle with DDOS and DOS at nginx level</title>
		<link>http://www.oneroot.ca/web-servers/nginx/struggle-with-ddos-and-dos-at-nginx-level</link>
		<comments>http://www.oneroot.ca/web-servers/nginx/struggle-with-ddos-and-dos-at-nginx-level#comments</comments>
		<pubDate>Fri, 21 Aug 2009 18:49:34 +0000</pubDate>
		<dc:creator>avatar</dc:creator>
				<category><![CDATA[nginx]]></category>
		<category><![CDATA[DOS and DDOS]]></category>
		<category><![CDATA[sysctl]]></category>

		<guid isPermaLink="false">http://www.oneroot.ca/?p=212</guid>
		<description><![CDATA[FreeBSD, network card: Intel fxp, port: 100Мбит, polling, http accept-filter.
&#160;

   in sysctl:
           sysctl kern.maxfiles=90000
           sysctl kern.maxfilesperproc=80000
           sysctl net.inet.tcp.blackhole=2
      [...]]]></description>
			<content:encoded><![CDATA[<p>FreeBSD, network card: Intel fxp, port: 100Мбит, polling, http accept-filter.<span id="more-212"></span></p>
<p>&nbsp;</p>
<pre>
   in sysctl:
           sysctl kern.maxfiles=90000
           sysctl kern.maxfilesperproc=80000
           sysctl net.inet.tcp.blackhole=2
           sysctl net.inet.udp.blackhole=1
           sysctl kern.polling.burst_max=1000
           sysctl kern.polling.each_burst=50
           sysctl kern.ipc.somaxconn=32768
           sysctl net.inet.tcp.msl=3000
           sysctl net.inet.tcp.maxtcptw=40960
           sysctl net.inet.tcp.nolocaltimewait=1
           sysctl net.inet.ip.portrange.first=1024
           sysctl net.inet.ip.portrange.last=65535
           sysctl net.inet.ip.portrange.randomized=0
</pre>
<p>&nbsp;</p>
<p>in <strong>nginx</strong> configuration:<br />
&nbsp;</p>
<pre>
           worker_processes 1;
           worker_rlimit_nofile 80000;
           events {
               worker_connections 50000;
           }

           server_tokens off;
           log_format IP `$remote_addr';
           reset_timedout_connection on;

           listen  xx.xx.xx.xx:80  default rcvbuf=8192 sndbuf=16384 backlog=32000 accept_filter=httpready;
</pre>
<p>&nbsp;</p>
<p>In the following way it is possible to realize filtration of url, in example for POST<br />
index.php?action=login which is with empty referral.</p>
<p>&nbsp;</p>
<pre>
           set $add 1;
           location /index.php {
                   limit_except GET POST {
                        deny all;
               }
               set $ban "";
               if ($http_referer = "" ) {set $ban $ban$add;}
               if ($request_method = POST ) {set $ban $ban$add;}
               if ($query_string = "action=login" ){set $ban $ban$add;}
               if ($ban = 111 ) {
                   access_log /var/log/[133]nginx/ban IP;
                   return 404;
               }
               proxy_pass http://127.0.0.1:8000; #here is a patch
           }
</pre>
<p>&nbsp;</p>
<p>Further we cut it at pf level &#8211; loaded into IP table, hosts from which came too many hits.<br />
PF with tables works very quickly. Sources for parsing of logs (ddetect) you can find on  http://www.comsys.com.ua/files<br />
Then Cron used once in a minute, to add into ip tables new IPs from a log.<br />
25 Mbyte DDoS, which cuts IPs, the rests fall on nginx which by it is criterion pass IPs and the rests passed on the apache &#8211; LA 0, site works.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneroot.ca/web-servers/nginx/struggle-with-ddos-and-dos-at-nginx-level/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

