<?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>Myatu&#039;s &#187; Linux</title>
	<atom:link href="http://www.myatus.co.uk/category/computing/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.myatus.co.uk</link>
	<description>Wasting bits and bytes daily</description>
	<lastBuildDate>Wed, 28 Jul 2010 19:03:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<atom:link rel='hub' href='http://www.myatus.co.uk/?pushpress=hub'/>
		<item>
		<title>Blocking w00tw00t scans</title>
		<link>http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/</link>
		<comments>http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 10:53:38 +0000</pubDate>
		<dc:creator>Myatu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.myatus.co.uk/?p=1401</guid>
		<description><![CDATA[Some websites are still being hit with the infamous &#8220;w00tw00t&#8221; scans. You might see these scans in your logs as: ... &#34;GET /w00tw00t.at.ISC.SANS.DFind:) HTTP/1.1&#34; 400 ... Using Iptables The quickest method of making sure it never reaches your webserver (and thus wasting resources like processor, disk space [log files], etc) is to use iptables, and [...]


Related posts:<ol><li><a href='http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/' rel='bookmark' title='Permanent Link: Guide: Firewall and router with Proxmox &#8211; Extending its use'>Guide: Firewall and router with Proxmox &#8211; Extending its use</a></li>
<li><a href='http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/' rel='bookmark' title='Permanent Link: Guide: Firewall and router with Proxmox'>Guide: Firewall and router with Proxmox</a></li>
<li><a href='http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/' rel='bookmark' title='Permanent Link: Faster WP Super Cache with NginX'>Faster WP Super Cache with NginX</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Some websites are still being hit with the infamous &#8220;w00tw00t&#8221; scans. You might see these scans in your logs as:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">... &quot;GET /w00tw00t.at.ISC.SANS.DFind:) HTTP/1.1&quot; 400 ...</div></div>
</pre>
<h3>Using Iptables</h3>
<p>The quickest method of making sure it never reaches your webserver (and thus wasting resources like processor, disk space [log files], etc) is to use iptables, and it can be done with a one-liner like this:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iptables <span style="color: #660033;">-I</span> INPUT <span style="color: #660033;">-d</span> xxx.xxx.xxx.xxx <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-m</span> string <span style="color: #660033;">--to</span> <span style="color: #000000;">70</span> &nbsp;<span style="color: #660033;">--algo</span> bm <span style="color: #660033;">--string</span> <span style="color: #ff0000;">'GET /w00tw00t.at.ISC.SANS.'</span> <span style="color: #660033;">-j</span> DROP</div></div>
</pre>
<p>Simply replace <em>xxx.xxx.xxx.xxx</em> with the IP of your web server. If you want to use this for a range of IPs (ie., you&#8217;re using multiple IPs to host web servers), simply replace the &#8220;-d xxx.xxx.xxx.xxx&#8221; portion with:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #660033;">-m</span> iprange <span style="color: #660033;">--dst-range</span> start.xxx.xxx.xxx-end.xxx.xxx.xxx</div></div>
</pre>
<p>where <em>start.xxx.xxx.xxx</em> and <em>end.xxx.xxx.xxx</em> are the first and last IPs of your web servers respectively.<span id="more-1401"></span></p>
<p>If you wish to have a fancier option, one where it will for example blacklist an IP for a certain period, etc., have a look at <a title="SpamCle@ner w00tw00t" href="http://spamcleaner.org/en/misc/w00tw00t.html" target="_blank">SpamCle@ner&#8217;s website</a>.</p>
<p>They go deeper into this subject and have provided two scripts near the end of their article. Simply save one of these scripts in a file named, for example, <em>/opt/blockw00t.sh</em> and make it executable with:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>blockw00t.sh</div></div>
</pre>
<p>You can run it manually with typing &#8220;/opt/blockwoot.sh&#8221; in the shell or to automatically load it at boot time you can add it to your <em>/etc/rc.local </em>file, or on Debian/Ubuntu systems add it to your <em>/etc/network/interfaces</em> like so:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">auto eth0<br />
inet eth0 static<br />
&nbsp; &nbsp;... [existing configuration that remains unaltered] ...<br />
&nbsp; &nbsp;# Load anti-w00t script:<br />
&nbsp; &nbsp;post-up /opt/blockw00t.sh</div></div>
</pre>
<h3>Using Fail2Ban</h3>
<p>If you are using <a title="Fail2Ban" href="http://www.fail2ban.org" target="_blank">Fail2Ban</a>, like described in the <a title="Guide: Firewall and router with Proxmox – Extending its use" href="http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/" target="_self">Shorewall firewall configuration</a>, you can create a new definition that scans for the w00tw00t entries in the webserver log files.</p>
<p>The following definition assumes your webserver log entries look like the following (Nginx and Apache 2):</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">203.127.11.214 - - [15/Jul/2010:15:50:04 +0200] &quot;GET /w00tw00t.at.ISC.SANS.test0:) HTTP/1.1&quot; 400 173 &quot;-&quot; &quot;-&quot;</div></div>
</pre>
<p>Create a file <em>/etc/fail2ban/filter.d/webserver-w00tw00t.conf</em>:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[Definition]<br />
failregex = ^&lt;HOST&gt; .*&quot;GET \/w00tw00t\.at\.ISC\.SANS\..+\:\).*?&quot;<br />
<br />
ignoreregex =</div></div>
</pre>
<p>This catches the known variants of the scanner, including &#8220;DFind&#8221;, &#8220;test0&#8243;, &#8220;MSlog&#8221; and &#8220;ntsvc&#8221;.</p>
<p>Note: The <em>&lt;HOST&gt;</em> portion is specific to fail2ban and is a shorthand for the regex <em>(?:::f{4,6}:)?(?P&lt;host&gt;\S+)</em>, which matches either an IPv4 or IPv6 address. See the <a title="Fail2Ban manual, filters" href="http://www.fail2ban.org/wiki/index.php/MANUAL_0_8#Filters" target="_blank">fail2ban manual</a> for more details.</p>
<p>*Tip: If you wish to change the regular expression, I recommend <a title="RegExr" href="http://gskinner.com/RegExr" target="_blank">RegExr</a> to play with various options/search criteria. It&#8217;s a time saver and free :)</p>
<p>*Tip 2: To test your definition&#8217;s regular expression, use:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">fail2ban-regex logfile <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>fail2ban<span style="color: #000000; font-weight: bold;">/</span>filter.d<span style="color: #000000; font-weight: bold;">/</span>webserver-w00tw00t.conf</div></div>
</pre>
<p>Where <em>logfile</em> is the actual log file name, such as <em>/var/log/apache2/access.log</em>.</p>
<p>Add this definition to the fail2ban Jail configuration (<em>/etc/fail2ban/jail.conf</em>):</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">... [existing configuration] ...<br />
<br />
[webserver-w00tw00t]<br />
enabled &nbsp;= true<br />
port &nbsp; &nbsp; = http,https<br />
filter &nbsp; = webserver-w00tw00t<br />
# !!! Keep in mind to specify the correct web server log here:<br />
logpath &nbsp;= /var/log/apache2/access.log<br />
maxretry = 1<br />
# Time in seconds, in this case, one day:<br />
bantime &nbsp;= 86400</div></div>
</pre>
<p>Now reload the service (ie., &#8220;/etc/init.d/fail2ban reload&#8221; or &#8220;service fail2ban reload&#8221;).</p>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/&amp;title=Blocking+w00tw00t+scans" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/&amp;title=Blocking+w00tw00t+scans" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/&amp;title=Blocking+w00tw00t+scans&amp;desc=Some%20websites%20are%20still%20being%20hit%20with%20the%20infamous%20%22w00tw00t%22%20scans.%20You%20might%20see%20these%20scans%20in%20your%20logs%20as%3A%0D%0A%5Bcce_text%5D...%20%22GET%20%2Fw00tw00t.at.ISC.SANS.DFind%3A%29%20HTTP%2F1.1%22%20400%20...%5B%2Fcce_text%5D%0D%0AUsing%20Iptables%0D%0AThe%20quickest%20method%20of%20making%20sure%20it%20never%20reaches%20your%20webserver%20%28and%20thus%20wasting%20resour" rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/&amp;imageurl=" rel="nofollow" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/&amp;bm_description=Blocking+w00tw00t+scans&amp;plugin=sexybookmarks" rel="nofollow" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/&amp;title=Blocking+w00tw00t+scans" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/&amp;title=Blocking+w00tw00t+scans" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/&amp;title=Blocking+w00tw00t+scans" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Blocking+w00tw00t+scans+-+http://bit.ly/cS3upS&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/' rel='bookmark' title='Permanent Link: Guide: Firewall and router with Proxmox &#8211; Extending its use'>Guide: Firewall and router with Proxmox &#8211; Extending its use</a></li>
<li><a href='http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/' rel='bookmark' title='Permanent Link: Guide: Firewall and router with Proxmox'>Guide: Firewall and router with Proxmox</a></li>
<li><a href='http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/' rel='bookmark' title='Permanent Link: Faster WP Super Cache with NginX'>Faster WP Super Cache with NginX</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A simplified Nginx-Apache combo with WordPress support</title>
		<link>http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/</link>
		<comments>http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 22:03:21 +0000</pubDate>
		<dc:creator>Myatu</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[benchmarking]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.myatus.co.uk/?p=617</guid>
		<description><![CDATA[It looks like I have neglected to write a new article in quite a while! Shame on me. But, thanks to a website outage, I&#8217;ve finally got some more good stuff to share with you. My previous Nginx configuration became a nightmare to maintain and WordPress had become slower because Apache&#8217;s children were being killed [...]


Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/' rel='bookmark' title='Permanent Link: NginX and Apache, but no memcached'>NginX and Apache, but no memcached</a></li>
<li><a href='http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/' rel='bookmark' title='Permanent Link: Faster WP Super Cache with NginX'>Faster WP Super Cache with NginX</a></li>
<li><a href='http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/' rel='bookmark' title='Permanent Link: Compiling NginX on Debian / Ubuntu'>Compiling NginX on Debian / Ubuntu</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" src="http://wiki.nginx.org/images/0/0e/Absolut_nginx.jpg" alt="Absolut Nginx" width="90" height="250" />It looks like I have neglected to write a new article in quite a while! Shame on me. But, thanks to a website outage, I&#8217;ve finally got some more good stuff to share with you.</p>
<p>My previous Nginx configuration became a nightmare to maintain and WordPress had become slower because Apache&#8217;s children were being killed by OOM. This was due to a  misguided PHP cache (PHP XCache to be precise) that decided to take every available bit of memory from my system, despite having max-requests per child set low (before it was purged).</p>
<p>This, along with my endeavors in seeking the fastest solution to everything and the introduction of a new Cloud servers by OVH, lead me to today&#8217;s article.<span id="more-617"></span></p>
<h2>Which is faster &#8211; Varnish or Nginx?</h2>
<p>The first thing I wanted to do is make all the caching happen before things get pushed through to Apache. This because I wanted to eliminate both PHP <a title="XCache" href="http://xcache.lighttpd.net" target="_blank">XCache</a> and the <a title="WP Super Cache" href="http://ocaoimh.ie/wp-super-cache" target="_blank">WordPress Super Cache</a> plugin I was using, so to increase WordPress compatibility but decrease complexity.</p>
<p>At first I thought about using <a title="Varnish Cache" href="http://varnish-cache.org" target="_blank">Varnish</a> &#8211; either as a the sole front-end, or in between Nginx and Apache (the reasoning later). Also, I had gotten my hands on OVH&#8217;s Cloud servers whilst they were still in <em>&#8220;alpha&#8221;</em>, and used this as the base system for building a pool of web servers.</p>
<p>The following tests have all been performed on those Cloud servers &#8211; mC 256 (256 MBytes of guaranteed RAM, 2 GByte total memory with excess swapped to SSD&#8217;s), 4 CPU cores and 5 GBytes of storage space. The OS is Ubuntu 10.04 LTS. The output of <em>/proc/cpuinfo</em> is as following (x4 for briefness):</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">processor &nbsp; &nbsp; &nbsp; : 0<br />
vendor_id &nbsp; &nbsp; &nbsp; : GenuineIntel<br />
cpu family &nbsp; &nbsp; &nbsp;: 6<br />
model &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : 26<br />
model name &nbsp; &nbsp; &nbsp;: Intel(R) Xeon(R) CPU &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; E5504 &nbsp;@ 2.00GHz<br />
stepping &nbsp; &nbsp; &nbsp; &nbsp;: 5<br />
cpu MHz &nbsp; &nbsp; &nbsp; &nbsp; : 1995.000<br />
cache size &nbsp; &nbsp; &nbsp;: 4096 KB<br />
fdiv_bug &nbsp; &nbsp; &nbsp; &nbsp;: no<br />
hlt_bug &nbsp; &nbsp; &nbsp; &nbsp; : no<br />
f00f_bug &nbsp; &nbsp; &nbsp; &nbsp;: no<br />
coma_bug &nbsp; &nbsp; &nbsp; &nbsp;: no<br />
fpu &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : yes<br />
fpu_exception &nbsp; : yes<br />
cpuid level &nbsp; &nbsp; : 11<br />
wp &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: yes<br />
flags &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf pni ssse3 cx16 sse4_1 sse4_2 popcnt hypervisor lahf_lm<br />
bogomips &nbsp; &nbsp; &nbsp; &nbsp;: 3990.00<br />
clflush size &nbsp; &nbsp;: 64<br />
cache_alignment : 64<br />
address sizes &nbsp; : 40 bits physical, 48 bits virtual<br />
power management:</div></div>
</pre>
<div>
<p>The stock install of Apache performed as following on a simple &#8220;Hello World&#8221; PHP script, using &#8220;<em>ab -c 100 -n 100000 http://host/</em>&#8220;:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Concurrency Level: &nbsp; &nbsp; &nbsp;100<br />
Time taken for tests: &nbsp; 29.548 seconds<br />
Complete requests: &nbsp; &nbsp; &nbsp;100000<br />
Failed requests: &nbsp; &nbsp; &nbsp; &nbsp;0<br />
Write errors: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0<br />
Total transferred: &nbsp; &nbsp; &nbsp;25009500 bytes<br />
HTML transferred: &nbsp; &nbsp; &nbsp; 3901482 bytes<br />
Requests per second: &nbsp; &nbsp;3384.27 [#/sec] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 29.548 [ms] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 0.295 [ms] (mean, across all concurrent requests)<br />
Transfer rate: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;826.55 [Kbytes/sec] received<br />
<br />
Connection Times (ms)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; min &nbsp;mean[+/-sd] median &nbsp; max<br />
Connect: &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; 12 &nbsp;39.1 &nbsp; &nbsp; 12 &nbsp; &nbsp;1960<br />
Processing: &nbsp; &nbsp; 9 &nbsp; 18 &nbsp;49.6 &nbsp; &nbsp; 14 &nbsp; &nbsp;2036<br />
Waiting: &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp; 15 &nbsp;45.9 &nbsp; &nbsp; 12 &nbsp; &nbsp;1966<br />
Total: &nbsp; &nbsp; &nbsp; &nbsp; 14 &nbsp; 29 &nbsp;65.9 &nbsp; &nbsp; 26 &nbsp; &nbsp;2159</div></div>
</pre>
<p>With Varnish in front of Apache, things really started to look good:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Concurrency Level: &nbsp; &nbsp; &nbsp;100<br />
Time taken for tests: &nbsp; 13.489 seconds<br />
Complete requests: &nbsp; &nbsp; &nbsp;100000<br />
Failed requests: &nbsp; &nbsp; &nbsp; &nbsp;0<br />
Write errors: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0<br />
Total transferred: &nbsp; &nbsp; &nbsp;28315282 bytes<br />
HTML transferred: &nbsp; &nbsp; &nbsp; 1100594 bytes<br />
Requests per second: &nbsp; &nbsp;7413.64 [#/sec] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 13.489 [ms] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 0.135 [ms] (mean, across all concurrent requests)<br />
Transfer rate: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2049.99 [Kbytes/sec] received<br />
<br />
Connection Times (ms)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; min &nbsp;mean[+/-sd] median &nbsp; max<br />
Connect: &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;6 &nbsp; 2.2 &nbsp; &nbsp; &nbsp;6 &nbsp; &nbsp; &nbsp;71<br />
Processing: &nbsp; &nbsp; 2 &nbsp; &nbsp;7 &nbsp; 1.9 &nbsp; &nbsp; &nbsp;7 &nbsp; &nbsp; &nbsp;70<br />
Waiting: &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp;6 &nbsp; 2.0 &nbsp; &nbsp; &nbsp;5 &nbsp; &nbsp; &nbsp;66<br />
Total: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3 &nbsp; 13 &nbsp; 3.1 &nbsp; &nbsp; 13 &nbsp; &nbsp; &nbsp;81</div></div>
</pre>
<p>At 2.48x more than what Apache can send out on its own, that&#8217;s a mighty impressive improvement and Varnish deserves kudos. But at 1 GBytes of RAM for caching, would it really be more efficient and quicker than Nginx? The following results tell &#8230;</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Concurrency Level: &nbsp; &nbsp; &nbsp;100<br />
Time taken for tests: &nbsp; 9.438 seconds<br />
Complete requests: &nbsp; &nbsp; &nbsp;100000<br />
Failed requests: &nbsp; &nbsp; &nbsp; &nbsp;0<br />
Write errors: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0<br />
Total transferred: &nbsp; &nbsp; &nbsp;27706648 bytes<br />
HTML transferred: &nbsp; &nbsp; &nbsp; 5201248 bytes<br />
Requests per second: &nbsp; &nbsp;10595.55 [#/sec] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 9.438 [ms] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 0.094 [ms] (mean, across all concurrent requests)<br />
Transfer rate: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2866.87 [Kbytes/sec] received<br />
<br />
Connection Times (ms)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; min &nbsp;mean[+/-sd] median &nbsp; max<br />
Connect: &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;4 &nbsp; 1.0 &nbsp; &nbsp; &nbsp;4 &nbsp; &nbsp; &nbsp;56<br />
Processing: &nbsp; &nbsp; 2 &nbsp; &nbsp;6 &nbsp; 9.7 &nbsp; &nbsp; &nbsp;5 &nbsp; &nbsp; 253<br />
Waiting: &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;5 &nbsp; 9.7 &nbsp; &nbsp; &nbsp;5 &nbsp; &nbsp; 253<br />
Total: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5 &nbsp; &nbsp;9 &nbsp; 9.7 &nbsp; &nbsp; &nbsp;9 &nbsp; &nbsp; 257</div></div>
</pre>
<p>&#8230; a different story. Though this is not some scientific research that should be taken at face value, I personally found the difference rather significant &#8211; especially since Nginx never used more than 60 Mbytes of RAM and relied mostly on system file  caching. 1.39x faster than Varnish, 3.46x faster than Apache by itself. That&#8217;s even more impressive!</p>
<h3>A little Varnish quirk on Ubuntu</h3>
<p>Again, and I can&#8217;t say this often enough, these are merely the numbers obtained on my system &#8211; your mileage may vary. Varnish is definitely a worthy contender &#8212; the one issue I encountered on Ubuntu was that Varnish crashed when attempting to test with more than 1000 concurrent connections. That&#8217;s not supposed to happen in a production environment!</p>
<p>The culprit seems to be the user account&#8217;s <em>&#8220;open file descriptors&#8221;</em> limitation. Sockets are also counted towards this value and when Varnish had hit the limit it died rather ungracefully. You can manually resolve it by using ulimit:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">ulimit</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">65535</span></div></div>
</pre>
<p>But you are better off using the <em>/etc/security/limits.conf</em> file. It is well documented, so it shouldn&#8217;t be to difficult to figure it out. I&#8217;ll continue with my blog&#8230;</p>
<h2>The Configuration</h2>
<p>So I have decided to keep Nginx as the front-end for Apache, but this time &#8211; unlike previously &#8211; activate Nginx&#8217;s caching. Doing it here, rather than working with caching plugins and a plethora of other band-aids, keeps the whole configuration clean and simple. Apache can be left alone to run as it normally does, with no special trickery. The only exception is a memcache store, because the database is located on a different server and linked through a VPN.</p>
<p>First I installed Nginx, Apache, PHP5 and Memcache through the usual channels, as following:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> nginx libapache2-mod-php5 memcached \<br />
php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick \<br />
php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming \<br />
php5-ps php5-pspell php5-recode php5-snmp php5-sqlite \<br />
php5-tidy php5-xmlrpc php5-xsl php5-json</div></div>
</pre>
<h3>Update Nginx</h3>
<p>The Nginx version provided by the Ubuntu repository is 0.7.65. However, a feature introduced in version 0.7.66/stable - <em>proxy_no_cache</em> &#8211; will come handy simplifying the configuration. 0.7.67 also fixed a small issue, which mainly concerns Windows machines but is good to have patched regardless. So I&#8217;ve compiled Nginx to the latest stable version as following:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># apt-get install libc6 libpcre3 libpcre3-dev libpcrecpp0 libssl0.9.8 libssl-dev zlib1g zlib1g-dev lsb-base</span><br />
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.nginx.org<span style="color: #000000; font-weight: bold;">/</span>download<span style="color: #000000; font-weight: bold;">/</span>nginx-0.7.67.tar.gz<br />
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xf</span> nginx-0.7.67.tar.gz<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> nginx-0.7.67<br />
.<span style="color: #000000; font-weight: bold;">/</span>configure \<br />
<span style="color: #660033;">--user</span>=www-data \<br />
<span style="color: #660033;">--group</span>=www-data \<br />
<span style="color: #660033;">--sbin-path</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin \<br />
<span style="color: #660033;">--conf-path</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf \<br />
<span style="color: #660033;">--error-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>error.log \<br />
<span style="color: #660033;">--pid-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>nginx.pid \<br />
<span style="color: #660033;">--lock-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>nginx.lock \<br />
<span style="color: #660033;">--http-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>access.log \<br />
<span style="color: #660033;">--http-client-body-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>body \<br />
<span style="color: #660033;">--http-proxy-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>proxy \<br />
<span style="color: #660033;">--http-fastcgi-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>fastcgi \<br />
<span style="color: #660033;">--with-debug</span> \<br />
--with-http_stub_status_module \<br />
--with-http_flv_module \<br />
--with-http_ssl_module \<br />
--with-http_dav_module \<br />
--with-http_gzip_static_module \<br />
--with-http_realip_module \<br />
<span style="color: #660033;">--with-mail</span> \<br />
--with-mail_ssl_module \<br />
<span style="color: #660033;">--with-ipv6</span><br />
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></div></div>
</pre>
<p>Yes, that&#8217;s literally cut &amp; paste. It overwrites the binaries installed by <em>apt-get</em>, and we happily continue to use the official init script provided by Ubuntu/Debian. Why make life difficult?</p>
<h3>Configuring PHP and Apache</h3>
<p>At this point, configure PHP and Apache to your heart&#8217;s content. The one thing that you need to do with Apache is move it to a different port and preferably keep it on 127.0.0.1. This means you need to edit the /etc/apache2/ports.conf file:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">NameVirtualHost *:8080<br />
Listen 127.0.0.1:8080</div></div>
</pre>
<p>And configure your website(s) accordingly:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;VirtualHost *:8080&gt;<br />
... etc ...<br />
&lt;/VirtualHost&gt;</div></div>
</pre>
<p>If you are using SSL (https://), this will be handled by Nginx rather than Apache. Since this is already getting quite long, I will skip SSL in this blog.</p>
<h3>Configuring Nginx</h3>
<p>We start off by creating a few directories that will be used by Nginx:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>includes<br />
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>tmp<br />
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>cached<br />
<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> www-data:www-data <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cache<span style="color: #000000; font-weight: bold;">/</span>nginx</div></div>
</pre>
<p>Next we modify the file <em>/etc/nginx/nginx.conf</em> as following:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">user &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;www-data;<br />
<br />
worker_processes &nbsp; &nbsp; &nbsp; &nbsp;4;<br />
worker_rlimit_nofile &nbsp; &nbsp;16384;<br />
<br />
error_log &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /var/log/nginx/error.log;<br />
pid &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /var/run/nginx.pid;<br />
<br />
events {<br />
&nbsp; &nbsp; &nbsp; &nbsp; worker_connections &nbsp;2000;<br />
}<br />
<br />
http {<br />
&nbsp; &nbsp; &nbsp; &nbsp; include &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /etc/nginx/mime.types;<br />
&nbsp; &nbsp; &nbsp; &nbsp; default_type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;application/octet-stream;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; access_log &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/var/log/nginx/access.log;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; sendfile &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;on;<br />
&nbsp; &nbsp; &nbsp; &nbsp; tcp_nopush &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;on;<br />
&nbsp; &nbsp; &nbsp; &nbsp; tcp_nodelay &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; on;<br />
&nbsp; &nbsp; &nbsp; &nbsp; keepalive_timeout &nbsp; &nbsp; &nbsp; 75 20;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; gzip &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;on;<br />
&nbsp; &nbsp; &nbsp; &nbsp; gzip_vary &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; on;<br />
&nbsp; &nbsp; &nbsp; &nbsp; gzip_comp_level &nbsp; &nbsp; &nbsp; &nbsp; 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; gzip_min_length &nbsp; &nbsp; &nbsp; &nbsp; 4096;<br />
&nbsp; &nbsp; &nbsp; &nbsp; gzip_proxied &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;any;<br />
&nbsp; &nbsp; &nbsp; &nbsp; gzip_types &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;text/plain text/css application/x-javascript text/xml<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; application/xml application/xml+rss text/javascript;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; include &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /etc/nginx/conf.d/*.conf;<br />
&nbsp; &nbsp; &nbsp; &nbsp; include &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /etc/nginx/sites-enabled/*;<br />
}</div></div>
</pre>
<p>The <em>worker_processes</em> variable is set according to the number of CPU cores in my system, 4 in this case. There are a few tcp tweaks and gzip compression is enabled on additional file types, rather than just html.  For the rest, it&#8217;s fairly run-of-the-mill.</p>
<p>The core workhorse of Nginx will be the proxy and its associated cache. Because I like to keep things nicely sectioned, thus easy to configure, I&#8217;ve created the following <em>/etc/nginx/conf.d/proxy.conf</em> file, which will be included by Nginx by an <em>include</em> statement:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">proxy_redirect &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;off;<br />
<br />
proxy_set_header &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Host $host;<br />
proxy_set_header &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;X-Forwarded-For $proxy_add_x_forwarded_for;<br />
<br />
proxy_connect_timeout &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 90;<br />
proxy_send_timeout &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;90;<br />
proxy_read_timeout &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;90;<br />
<br />
proxy_buffer_size &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 4k;<br />
proxy_buffers &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 4 32k;<br />
proxy_busy_buffers_size &nbsp; &nbsp; &nbsp; &nbsp; 64k;<br />
proxy_temp_file_write_size &nbsp; &nbsp; &nbsp;64k;<br />
<br />
proxy_max_temp_file_size &nbsp; &nbsp; &nbsp; &nbsp;56m;<br />
proxy_temp_path &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /var/cache/nginx/tmp;<br />
proxy_cache_key &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $scheme$host$request_uri;<br />
proxy_cache_path &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/var/cache/nginx/cached levels=2:2 keys_zone=global:64m inactive=60m max_size=1G;<br />
<br />
proxy_cache_valid &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 200 302 30m;<br />
proxy_cache_valid &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 301 1h;<br />
proxy_cache_valid &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 404 1m;<br />
<br />
proxy_cache_use_stale &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error timeout http_500 http_502 http_503 http_504;<br />
<br />
proxy_pass_header &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set-Cookie;</div></div>
</pre>
<p>The <em>proxy_set_header</em> variables are there to help you determine the IP of the actual web page requester, rather than receiving the one from Nginx. You just need to include <em>%{X-Forwarded-For}i</em> in one of Apache&#8217;s log formats instead of the host (<em>%h</em>).</p>
<p>However, I have personally disabled all access logging in Apache, because everything needs to pass through Nginx anyway and it boosts Apache&#8217;s performance a smidgen (you do this by commenting out all the <em>CustomLog</em> lines in Apache&#8217;s configurations). I did leave the Apache <em>ErrorLog</em> enabled, just for those instances and also for PHP error messages.</p>
<p>The file above also defines an Nginx proxy cache zone called <em>&#8220;global&#8221;</em> with the <em>proxy_cache_path</em> variable. That same variable also specifies a garbage time (60 minutes) and maximum cache size (on the disk, 1 Gbytes).</p>
<p>The <em>proxy_cache_key</em> is simply a concatenation of <em>&#8220;httpmyatus.co.uk/therequests.php&#8221;</em> that will be hashed and then used to retrieve it at a later point. I&#8217;m allowing stale cache to be served in case of certain errors, for example when Apache has unexpectedly died.</p>
<p>An important bit, which was quite a PITA to figure out, is the <em>proxy_pass_header</em> portion for the <em>&#8220;Set-Cookie&#8221;</em> header. WordPress includes <em>&#8220;Set-Cookie&#8221;</em> headers in 302 HTTP responses (which is used to point your browser to a new location) &#8211; some frown upon this practice and Nginx is no exception. Hence we need to specifically let this pass through, or else you will not be able to login to your WordPress Admin or have users leave comments.</p>
<h3>Includes</h3>
<p>In the <em>/etc/nginx/includes</em> folder we created earlier, we add two files. The first is a helper for sites that use WordPress. Since the <em>/etc/nginx/includes</em> folder is not automatically included, we can be selective about inclusions, and save on some processing time when these features aren&#8217;t used. This is the <em>/etc/nginx/includes/wordpress.inc</em> file:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">if ($http_cookie ~* &quot;comment_author_|wordpress_(?!test_cookie)|wp-postpass_&quot;) {<br />
&nbsp; &nbsp; set $no_cache 1;<br />
}<br />
<br />
if ($http_user_agent ~* &quot;(2\.0 MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine\/3\.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA\/WX310K|LG\/U990|MIDP-2\.|MMEF20|MOT-V|NetFront|Newt|Nintendo Wii|Nitro|Nokia|Opera Mini|Palm|PlayStation Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian OS|SymbianOS|TS21i-10|UP\.Browser|UP\.Link|webOS|Windows CE|WinWAP|YahooSeeker\/M1A1-R2D2|NF-Browser|iPhone|iPod|Android|BlackBerry9530|G-TU915 Obigo|LGE VX|webOS|Nokia5800)&quot; ) {<br />
&nbsp; &nbsp; set $no_cache 1;<br />
}<br />
<br />
proxy_no_cache&nbsp; &nbsp; &nbsp; $no_cache;</div></div>
</pre>
<p>It&#8217;s a very simple file, actually. The first portion checks if there are certain cookies set, related to comment authors or those who are logged into the WordPress Admin. If this is the case, the variable <em>$no_cache</em> is set to 1. The second check is for mobile users, like Nokia, iPhone, etc. This is helpful in case you have a mobile WordPress edition, as available through some plugins.</p>
<p>If at any point the <em>$no_cache</em> is 1, the variable <em>proxy_no_cache</em> becomes true. Apache&#8217;s output might still be cached, but it will not be served to the end user (thus always fresh).</p>
<p>The second file is a helper that&#8217;s pretty much universal for all the websites (but can still be overridden in the actual <em>sites-available/*</em> files). This is the <em>/etc/nginx/includes/default_proxy.inc</em> file:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># Enable caching:<br />
proxy_cache &nbsp; &nbsp; global;<br />
<br />
# Default:<br />
location / {<br />
&nbsp; &nbsp; &nbsp; &nbsp; proxy_pass &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;http://127.0.0.1:8080;<br />
}<br />
<br />
# Rarely changed items can remain cached longer:<br />
location ~* \.(jpg|jpeg|png|gif|ico|css|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx)$ {<br />
&nbsp; &nbsp; &nbsp; &nbsp; proxy_cache_valid &nbsp; &nbsp; &nbsp; 200 3h;<br />
&nbsp; &nbsp; &nbsp; &nbsp; proxy_pass &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;http://127.0.0.1:8080;<br />
}<br />
<br />
# Deny access to .ht* files:<br />
location ~ /\.ht {<br />
&nbsp; &nbsp; &nbsp; &nbsp; deny &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;all;<br />
}</div></div>
</pre>
<p>The first variable <em>proxy_cache </em>informs Nginx to use the <em>&#8220;global&#8221;</em> zone we defined earlier in the <em>/etc/nginx/conf.d/proxy.conf </em>file. If it is not there, nothing will be cached and pages simply pass through.</p>
<p>It further tells Nginx to send everything to Apache, but allow images and a few other static files to be cached longer than originally defined. The last portion tells Nginx to block access to files such as <em>.htaccess</em> or <em>.htpasswd</em> right at Nginx&#8217;s level &#8211; so Apache doesn&#8217;t have to and save some processing power.</p>
<h3>A default site</h3>
<p>You can use the include files to build a very small website configuration file. For example, <em>/etc/nginx/sites-available/</em>default may looks something similar to this:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">server {<br />
&nbsp; &nbsp; &nbsp; &nbsp; listen &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;80;<br />
&nbsp; &nbsp; &nbsp; &nbsp; server_name &nbsp; &nbsp; _;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/var/www/sites/default/public;<br />
&nbsp; &nbsp; &nbsp; &nbsp; index &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index.html index.htm;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; access_log &nbsp; &nbsp; &nbsp;/var/www/sites/default/logs/access.log;<br />
&nbsp; &nbsp; &nbsp; &nbsp; error_log &nbsp; &nbsp; &nbsp; /var/www/sites/default/logs/nginx.error.log;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # Includes:<br />
&nbsp; &nbsp; &nbsp; &nbsp; include &nbsp; &nbsp; &nbsp; &nbsp; /etc/nginx/includes/wordpress.inc;<br />
&nbsp; &nbsp; include &nbsp; &nbsp; &nbsp; &nbsp; /etc/nginx/includes/default_proxy.inc;<br />
}</div></div>
</pre>
<p>Everything is passed to Apache and cached, depending of the <em>wordpress.inc</em> file allows it. Apache will handle the rest. You will likely have to change the directories, but that&#8217;s basically it.</p>
<h2>WordPress</h2>
<p>There&#8217;s little that needs to be done with WordPress. The most important thing is to actually disable any WordPress cache you may be using, such as WordPress Super Cache. It is no longer needed and only gives Apache / PHP more work to do. However, as noted earlier, I did include Memcache.</p>
<p>The reason is that in my case, each Cloud server works off the same MySQL database cluster. To avoid unnecessary or repetitive SQL traffic, the Memcache daemon will hold these in RAM memory (or in the Cloud&#8217;s case &#8211; either RAM or SSD). This is done with the use of the <em>object-cache.php</em> file by Ryan Boren, which can be obtained <a title="WordPress Memcached object-cache" href="http://plugins.trac.wordpress.org/browser/memcached/" target="_blank">from this website</a>. This file needs to be placed in your <em>$WP-ROOT$/wp-content/</em> directory.</p>
<p>For everything else, WordPress can be plain vanilla but become blistering fast, as shown in the next output.</p>
<h2>Performance</h2>
<p>I have clustered a Cloud server with a dedicated server. For a short while (as in, half a day) I used HAProxy as the point-of-entry. HAProxy is super-fast, but I was irked by a minor issue that caused some logging issues. Nginx is on-par with HAProxy, though it might have a little more jitter, so I now use an 2x Nginx &lt;&#8211;&gt; 2x (Nginx + Apache) combination. Witt the (Nginx + Apache) portion of this setup configured exactly as described above, I have been able to obtain the following speeds (based on 100 concurrent connections, 50,000 requests and keep-alive enabled):</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Concurrency Level: &nbsp; &nbsp; &nbsp;100<br />
Time taken for tests: &nbsp; 6.694 seconds<br />
Complete requests: &nbsp; &nbsp; &nbsp;50000<br />
Failed requests: &nbsp; &nbsp; &nbsp; &nbsp;0<br />
Write errors: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0<br />
Keep-Alive requests: &nbsp; &nbsp;0<br />
Total transferred: &nbsp; &nbsp; &nbsp;2822197200 bytes<br />
HTML transferred: &nbsp; &nbsp; &nbsp; 2806393092 bytes<br />
Requests per second: &nbsp; &nbsp;7469.02 [#/sec] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 13.389 [ms] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 0.134 [ms] (mean, across all concurrent requests)<br />
Transfer rate: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;411700.31 [Kbytes/sec] received<br />
<br />
Connection Times (ms)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; min &nbsp;mean[+/-sd] median &nbsp; max<br />
Connect: &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;2 &nbsp; 0.4 &nbsp; &nbsp; &nbsp;2 &nbsp; &nbsp; &nbsp;16<br />
Processing: &nbsp; &nbsp; 3 &nbsp; 11 &nbsp; 0.8 &nbsp; &nbsp; 11 &nbsp; &nbsp; &nbsp;27<br />
Waiting: &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp;3 &nbsp; 1.2 &nbsp; &nbsp; &nbsp;3 &nbsp; &nbsp; &nbsp;25<br />
Total: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;6 &nbsp; 13 &nbsp; 0.8 &nbsp; &nbsp; 13 &nbsp; &nbsp; &nbsp;32</div></div>
</pre>
<p>At 3.29 Gbps @ 7469 requests per second, I consider this to be a rather well performing setup. Well prepared for my next project!</p>
</div>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/&amp;title=A+simplified+Nginx-Apache+combo+with+Wordpress+support" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/&amp;title=A+simplified+Nginx-Apache+combo+with+Wordpress+support" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/&amp;title=A+simplified+Nginx-Apache+combo+with+Wordpress+support&amp;desc=It%20looks%20like%20I%20have%20neglected%20to%20write%20a%20new%20article%20in%20quite%20a%20while%21%20Shame%20on%20me.%20But%2C%20thanks%20to%20a%20website%20outage%2C%20I%27ve%20finally%20got%20some%20more%20good%20stuff%20to%20share%20with%20you.%0D%0A%0D%0AMy%20previous%20Nginx%20configuration%20became%20a%20nightmare%20to%20maintain%20and%20WordPress%20had%20become%20slower%20because%20Apache%27s%20children%20w" rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/&amp;imageurl=" rel="nofollow" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/&amp;bm_description=A+simplified+Nginx-Apache+combo+with+Wordpress+support&amp;plugin=sexybookmarks" rel="nofollow" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/&amp;title=A+simplified+Nginx-Apache+combo+with+Wordpress+support" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/&amp;title=A+simplified+Nginx-Apache+combo+with+Wordpress+support" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/&amp;title=A+simplified+Nginx-Apache+combo+with+Wordpress+support" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=A+simplified+Nginx-Apache+combo+with+Wordpress+support+-+http://bit.ly/abDc4R&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/' rel='bookmark' title='Permanent Link: NginX and Apache, but no memcached'>NginX and Apache, but no memcached</a></li>
<li><a href='http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/' rel='bookmark' title='Permanent Link: Faster WP Super Cache with NginX'>Faster WP Super Cache with NginX</a></li>
<li><a href='http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/' rel='bookmark' title='Permanent Link: Compiling NginX on Debian / Ubuntu'>Compiling NginX on Debian / Ubuntu</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Guide: Firewall and router with Proxmox &#8211; Extending its use</title>
		<link>http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/</link>
		<comments>http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 09:08:55 +0000</pubDate>
		<dc:creator>Myatu</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[fail2ban]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[proxmox]]></category>
		<category><![CDATA[shorewall]]></category>

		<guid isPermaLink="false">http://www.myatus.co.uk/?p=505</guid>
		<description><![CDATA[Last year I wrote a guide on how to use Shorewall as a firewall and router for Proxmox. As a follow up I will answer a few questions I&#8217;ve received about that guide that can help you extend its use. Proxy ARP The most common question is in regards to proxy ARP. Enabling this option [...]


Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/' rel='bookmark' title='Permanent Link: Guide: Firewall and router with Proxmox'>Guide: Firewall and router with Proxmox</a></li>
<li><a href='http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/' rel='bookmark' title='Permanent Link: Blocking w00tw00t scans'>Blocking w00tw00t scans</a></li>
<li><a href='http://www.myatus.co.uk/2009/08/24/guide-installing-opensolaris-on-a-remote-dedicated-server/' rel='bookmark' title='Permanent Link: Guide: Installing OpenSolaris on a remote dedicated server'>Guide: Installing OpenSolaris on a remote dedicated server</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-thumbnail wp-image-526" title="Online Hoodies" src="http://www.myatus.co.uk/wp-content/uploads/2010/03/online_hoodies-150x150.jpg" alt="&quot;Metro rebrands Hackers&quot; by gwire, attribution license" width="150" height="150" />Last year I wrote a guide on <a title="Guide: Firewall and router with Proxmox" href="http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/">how to use Shorewall as a firewall and router for Proxmox</a>. As a follow up I will answer a few questions I&#8217;ve received about that guide that can help you extend its use.</p>
<h2>Proxy ARP</h2>
<p>The most common question is in regards to <em>proxy ARP</em>. Enabling this option will allow you to assign a public IP directly to your guest VM, eliminating the need for port forwarding (DNAT) or having to worry about the MAC address.</p>
<p>As an example use for proxy ARP, it is helpful for those using a a SIP-based VoIP server since a STUN server is no longer required.<span id="more-505"></span></p>
<h3>Enabling Proxy ARP</h3>
<p>The first step is to ensure that Proxy ARP is enabled.  This is a fairly simple task and involves adding an single line to one of your static network stanzas. Which one precisely depends on your system setup; for those who have an <em>eth0</em> stanza, you can use it there. For others who only have a <em>vmbr0..n</em> stanza, the additional line should be placed there.</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iface eth0 inet static<br />
&nbsp; &nbsp; # ... existing lines ...<br />
&nbsp; &nbsp; post-up echo 1 &gt; /proc/sys/net/ipv4/conf/all/proxy_arp</div></div>
</pre>
<p>These changes will take effect on your next boot or whenever you restart your networking services.</p>
<h3>Add a route to Shorewall</h3>
<p>Shorewall needs to know that you&#8217;d like to use proxy ARP, for which IP that is and where this IP needs to be routed to. The beauty of Shorewall is its simplicity and so this can be quickly done by creating a file named <em>/etc/shorewall/proxyarp</em> that will contain this:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#ADDRESS    INTERFACE    EXTERNAL    HAVEROUTE    PERSISTENT<br />
92.22.33.44 vmbr0 &nbsp; &nbsp; &nbsp; &nbsp;eth0</div></div>
</pre>
<p>Translated, this informs Shorewall that the public IP 92.22.33.44 attached to <em>eth0</em> needs to be forwarded to a guest VM (using this public IP) attached to the <em>vmbr0</em> bridge.</p>
<p>As you can tell from the first line, there are two additional options: <em>haveroute</em> and <em>persistent</em>.</p>
<p>The <em>haveroute</em> option determines whether Shorewall should create a route from the external interface to the bridge. For guest containers based on OpenVZ, Proxmox will take of creating the route. But for fully virtualised containers (based on KVM), you need to create this route yourself. In this case we tell Shorewall to create the route for us, by keep this option&#8217;s value at its default value (blank, or <em>No</em>).</p>
<p>When the <em>haveroute</em> option is set to No (default), the <em>persistent</em> option tells Shorewall if it should keep the created route active if Shorewall is stopped. Generally, and for security reasons, you should leave this at its default option (blank or <em>No</em>). This prevents the guest VM from being exposed without a firewall protecting it.</p>
<h3>Creating Shorewall rules</h3>
<p>In the original guide all traffic from the public side to internal VMs is blocked. This continues to be the same when you are using proxy ARP and thus need to create rules that permit traffic to certain ports. This can be done by adding rules like:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ACCEPT    net    dmz:92.22.33.44    udp    5060</div></div>
</pre>
<p>This will permit UDP traffic on port 5060 to proceed to the guest VM on IP 92.22.33.44. You can also use the Shorewall macros, for example:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HTTP/ACCEPT    net     dmz:92.22.33.44</div></div>
</pre>
<p>And in this case it will make a web server on 92.22.33.44 accessible to the public.</p>
<p>Alternatively, you may setup a single rule that accepts all traffic on  all ports:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ACCEPT    net     dmz:92.22.33.44</div></div>
</pre>
<p>However you should take care that the guest VM has its own set of rules to block unwanted or unsafe traffic.</p>
<p>The main thing to take care of with these proxy ARP firewall rules is to use <em>&#8220;ACCEPT&#8221;</em> and not <em>&#8220;DNAT&#8221;</em> as explained in the original guide.</p>
<h2>Multiple public IPs</h2>
<p>Another common question is in regards to multiple public IP addresses. The original guide assumed that the host has one public IP address, so here are a few additional pointers.</p>
<p>If you are following the original guide, then <em>any</em> public IP will be applied the same rule. So let&#8217;s say you have two public IP addresses, 94.11.22.33 and 94.22.33.44 and the following rule:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ACCEPT    net    fw    tcp    5900:5999</div></div>
</pre>
<p>With this rule, you can use both 93.11.22.33:5900 or 94.22.33.44:5900 to connect to Proxmox&#8217;s VNC. But you wish to restrict it to a specific IP address, then you need to modify the rule as following:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ACCEPT    net   fw:94.22.33.44    tcp    5900:5999</div></div>
</pre>
<p>Now you can only use 94.22.33.44:5900 to connect, but not 93.11.22.33:5900.</p>
<p>The same applies to port forwarding (DNAT) rules, which is written in a slightly different format. Let&#8217;s say we have this rule:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DNAT    net    dmz:10.0.0.1    tcp    1234</div></div>
</pre>
<p>This will forward <em>any</em> public IP to port 1234 on the guest VM at 10.0.0.1. So both 94.11.22.33:1234 and 94.22.33.44:1234 will work. If you wish to restrict this to a certain public IP address, the rule needs to be modified as following:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DNAT    net    dmz:10.0.0.1    tcp    1234    -    94.22.33.44</div></div>
</pre>
<p>Only 94.22.33.44:1234 will be allowed at this point.</p>
<h3>Memorable names</h3>
<p>If you have many IP addresses, it becomes easy to forget which IP to use. You can use Shorewall&#8217;s &#8220;params&#8221; file to give IPs a memorable name. Edit the file <em>/etc/shorewall/params</em> as following:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">IP_ALEX=94.11.22.33<br />
IP_SONIA=94.22.33.44<br />
IP_ERIC=94.33.44.55<br />
IP_VM1=10.0.0.1<br />
IP_VM2=10.0.0.2<br />
IP_VM3=10.0.0.3</div></div>
</pre>
<p>Now you can use these names instead of the IP address in any of your Shorwall rules, like so:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HTTP/DNAT    net     dmz:$IP_VM1    -    -    -    $IP_SONIA</div></div>
</pre>
<p>And this would forward HTTP traffic from 94.22.33.44 to a guest VM running on 10.0.0.1.</p>
<h2>Mixed use and bridging</h2>
<p>The original guide not only adds a firewall, but also helped those who&#8217;s hosting provided blocked IPs on unauthorized MACs. One such hosting provided was OVH, and they have recently introduced a &#8220;Virtual MACs for VPS&#8221; option that allows you to assign an IP address to a MAC. This eliminates the need for Proxy ARP or port forwarding/NAT, however the original guide will still prove itself useful for protecting the host.</p>
<p>I will provide a sample setup below, which can be modified to suit your needs and network configuration. This assumes you have have a basic understanding of networking and read my <a title="Guide: Firewall and router with Proxmox" href="http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/">previous guide</a>.</p>
<h3>Interfaces</h3>
<p>We modify the <em>/etc/network/interfaces</em> as following:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># The loopback network interface<br />
auto lo<br />
iface lo inet loopback<br />
<br />
# Public Network. Make sure to only use MACs that were assigned to you<br />
auto vmbr0<br />
iface vmbr0 inet static<br />
&nbsp;# The following settings are specific to your hosting provider:<br />
&nbsp;address 94.11.22.33<br />
&nbsp;netmask 255.255.255.0<br />
&nbsp;network 94.11.22.0<br />
&nbsp;broadcast 94.11.22.255<br />
&nbsp;gateway 94.11.22.254<br />
&nbsp;# The following assumes eth0 is the public-side NIC, the remained is always the same<br />
&nbsp;bridge_ports eth0<br />
&nbsp;bridge_stp off<br />
&nbsp;bridge_fd<br />
<br />
# Optional Private Network. This network cannot be access directly from the public side<br />
auto vmbr1<br />
iface vmbr1 inet auto<br />
 address 10.0.0.1<br />
 network 255.0.0.0<br />
 broadcast 10.255.255.25<br />
&nbsp;bridge_ports none<br />
 bridge_stp off<br />
 bridge_fd 0</div></div>
</pre>
<p>The host, accessible by 94.11.22.33, will have two bridges at this point: <em>vmbr0</em> serving the public-side and <em>vmbr1</em> serving inter-VM communication.</p>
<p>To assign a public IP address to a KVM, you use the <em>vmbr0</em> bride and must ensure the MAC corresponds to the one provided by your hosting provider (if a MAC restriction is in place).</p>
<p>You can also add a 2nd NIC (or as the only NIC) to the KVM, which is bridged with <em>vmbr1</em>. In this case, you need to use an IP within the 10.0.0.2-10.255.255.254 range, and as gateway 10.0.0.1. This particular IP range can only be used between other VMs on the same host / bridge, unless you use port forwarding or a VPN on the same IP range.</p>
<h3>Shorewall Interfaces and Zones</h3>
<p>The basic <em>/etc/shorewall/interfaces</em> will be:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#ZONE    INTERFACE    BROADCAST    OPTIONS<br />
pub    vmbr0        detect        routeback,bridge<br />
loc    vmbr1        detect        routeback,bridge<br />
<br />
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE</div></div>
</pre>
<p>You could also add the <em>blacklist</em> option, or any of the other possible Shorewall options if you wish.</p>
<p>The accompanying /etc/shorewall/zones will look like this:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#ZONE    TYPE        OPTIONS        IN            OUT<br />
#                    OPTIONS            OPTIONS<br />
fw    firewall<br />
pub    ipv4<br />
loc    ipv4<br />
<br />
#LAST LINE - ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE</div></div>
</pre>
<p>You now have three distinct Shorewall zones. The <em>fw</em> zone is a self-reference to the host (in our sample setup 94.11.22.33 and 10.0.0.1). The <em>pub</em> zone represents the publicly accessible <em>vmbr0</em> bridge and <em>loc</em> our internal <em>vmbr1</em> bridge.</p>
<h3>Shorewall Policy</h3>
<p>The following policy defines these basic rules:</p>
<ul>
<li>Traffic from the the host anywhere else is permitted</li>
<li>Traffic from the public side to the host and the internal network is denied</li>
<li>Traffic from the internal side to the host is denied, anywhere else is permitted</li>
</ul>
<p>Edit <em>/etc/shorewall/policy</em>:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#SOURCE    DEST    POLICY        LOG    LIMIT:        CONNLIMIT:<br />
#                    LEVEL    BURST        MASK<br />
<br />
# From Firewall:<br />
fw        fw    ACCEPT<br />
fw        pub    ACCEPT<br />
fw        loc    ACCEPT<br />
<br />
# Public Bridge (read the policy warnings!):<br />
pub        pub    ACCEPT<br />
pub        loc    ACCEPT<br />
pub        fw    DROP        info<br />
<br />
# Local (internal) Bridge:<br />
loc        loc    ACCEPT<br />
loc        pub    ACCEPT<br />
loc        fw    DROP        info<br />
<br />
# THE FOLLOWING POLICY MUST BE LAST<br />
#<br />
all    all    REJECT        info<br />
<br />
#LAST LINE -- DO NOT REMOVE</div></div>
</pre>
<h3>Policy Warnings</h3>
<p>With this sample policy it means that <span style="text-decoration: underline;">each publicly accessible guest VM should have its own firewall</span>. If you wish to change this behavior, and let Shorewall handle the firewall for each such guest VM, then change the Public Bridge section:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">pub        pub    DROP &nbsp; &nbsp; &nbsp;info</div></div>
</pre>
<p>You then need to create specific rules that allow traffic to VMs on <em>vmbr0</em>.</p>
<p>A similar warning applies to traffic from <em>vmbr0</em> to <em>vmbr1</em>. The policy assumes that <em>vmbr0</em> does not receive any routable traffic on a private IP range (also called <em>&#8220;martians&#8221;</em>). Although this is often the case, it depends on the hosting provider&#8217;s internal networking. If you are not sure whether there&#8217;s routable traffic on a private IP range from the public side, you have two options. The first is to disallow all traffic from <em>vmbr0</em> (pub) to <em>vmbr1</em> (loc) by editing the Public Bridge section:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">pub        loc    DROP &nbsp; &nbsp; &nbsp;info</div></div>
</pre>
<p>The alternative is to have a set of rules in <em>/etc/shorewall/rules</em> like so:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># ...<br />
SECTION NEW<br />
<br />
# Leave these at the top, right after &quot;SECTION NEW&quot;!<br />
DROP        pub:10.0.0.0/8        all<br />
DROP        pub:192.168.0.0/16    all<br />
DROP        pub:172.168.0.0/12    all<br />
<br />
# ... Other rules follow ...<br />
<br />
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE</div></div>
</pre>
<blockquote><p><strong>In all cases, you should verify whether traffic is truly blocked and never assume that it is!<br />
</strong></p></blockquote>
<h2>Shorewall and Fail2ban</h2>
<p><a title="Fail2ban" href="http://www.fail2ban.org/" target="_blank"><img class="alignleft size-full wp-image-523" title="Fail2ban Logo" src="http://www.myatus.co.uk/wp-content/uploads/2010/03/fail2ban_logo.png" alt="" width="135" height="130" />Fail2ban</a> in its own words <em>&#8220;scans log files like /var/log/pwdfail or /var/log/apache/error_log and bans IP that makes too many password failures. It updates firewall rules to reject the IP address&#8221;</em>. This can for instance be used to (temporarily) ban a bot that is attempting a brute-force entry through SSH.</p>
<p>Fail2ban is an ideal companion to Shorewall and can be installed in a matter of minutes on a Proxmox host. You start by installing Fail2ban from the Debian packages:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> fail2ban</div></div>
</pre>
<h3>Configure Shorewall</h3>
<p>Next you need to edit one line in the Shorewall configuration file, located at <em>/etc/shorewall/shorewall.conf</em>:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">BLACKLISTNEWONLY=No</div></div>
</pre>
<p>That&#8217;s all you need to configure in Shorewall. Remember to apply your settings by restarting Shorewall with the command <em>&#8220;shorewall restart&#8221;</em>.</p>
<h3>Configure Fail2ban</h3>
<p>The last step is to configure Fail2ban. The file <em>/etc/fail2ban/jail.conf</em> is extensively documented and of particular interest are the following settings:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">...<br />
#<br />
# Destination email address used solely for the interpolations in<br />
# jail.{conf,local} configuration files.<br />
destemail = myemail@address.com<br />
<br />
...<br />
#<br />
# ACTIONS<br />
#<br />
<br />
# Default banning action (e.g. iptables, iptables-new,<br />
# iptables-multiport, shorewall, etc) It is used to define<br />
# action_* variables. Can be overriden globally or per<br />
# section within jail.local file<br />
banaction = shorewall<br />
<br />
...<br />
# Choose default action.  To change, just override value of 'action' with the<br />
# interpolation to the chosen action shortcut (e.g.  action_mw, action_mwl, etc$<br />
# globally (section [DEFAULT]) or per specific section<br />
action = %(action_mwl)s</div></div>
</pre>
<p>Inform fail2ban of these changes by issuing the following command:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">fail2ban-client reload</div></div>
</pre>
<p>The <em>destemail</em> variable should be changed to your own e-mail address, where you will be informed of any ban actions. The <em>banaction</em> variable specifies that Shorewall should be used to block possible intruders. And finally, the <em>action</em> variable tells fail2ban to ban any detected intruder and then send an you a detailed e-mail with the relevant log lines (that caused the ban). Following is an example of an actual e-mail:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Hi,<br />
<br />
The IP 193.86.5.103 has just been banned by Fail2Ban after<br />
3 attempts against ssh.<br />
<br />
Here are more information about 193.86.5.103:<br />
<br />
% This is the RIPE Database query service.<br />
% The objects are in RPSL format.<br />
%<br />
% The RIPE Database is subject to Terms and Conditions.<br />
% See &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://www.ripe.net/db/support/db-terms-conditions.pdf&quot;&gt;http://www.ripe.net/db/support/db-terms-conditions.pdf&lt;/a&gt;<br />
<br />
% Note: This output has been filtered.<br />
% &nbsp; &nbsp; &nbsp; To receive output for a database update, use the &quot;-B&quot; flag.<br />
<br />
% Information related to '193.86.4.0 - 193.86.5.255'<br />
<br />
inetnum: &nbsp; &nbsp; &nbsp;193.86.4.0 - 193.86.5.255<br />
netname: &nbsp; &nbsp; &nbsp;BRANO<br />
descr: &nbsp; &nbsp; &nbsp; &nbsp;BRANO, Inc.<br />
descr: &nbsp; &nbsp; &nbsp; &nbsp;Hradec nad Moravici<br />
country: &nbsp; &nbsp; &nbsp;CZ<br />
admin-c: &nbsp; &nbsp; &nbsp;BK230-RIPE<br />
tech-c: &nbsp; &nbsp; &nbsp; TP231-RIPE<br />
status: &nbsp; &nbsp; &nbsp; ASSIGNED PA<br />
mnt-by: &nbsp; &nbsp; &nbsp; GTSCZ-MNT<br />
source: &nbsp; &nbsp; &nbsp; RIPE # Filtered<br />
<br />
person: &nbsp; &nbsp; &nbsp; Bohumil Kriz<br />
address: &nbsp; &nbsp; &nbsp;BRANO, Inc.<br />
address: &nbsp; &nbsp; &nbsp;Computer Centre<br />
address: &nbsp; &nbsp; &nbsp;Hradec nad Moravici<br />
address: &nbsp; &nbsp; &nbsp;747 41<br />
address: &nbsp; &nbsp; &nbsp;The Czech Republic<br />
phone: &nbsp; &nbsp; &nbsp; &nbsp;+420 653 918118<br />
fax-no: &nbsp; &nbsp; &nbsp; +420 653 911791<br />
nic-hdl: &nbsp; &nbsp; &nbsp;BK230-RIPE<br />
source: &nbsp; &nbsp; &nbsp; RIPE # Filtered<br />
<br />
person: &nbsp; &nbsp; &nbsp; Tomas Partl<br />
address: &nbsp; &nbsp; &nbsp;Brano, Inc.<br />
address: &nbsp; &nbsp; &nbsp;Computer Centre<br />
address: &nbsp; &nbsp; &nbsp;Hradec nad Moravici<br />
address: &nbsp; &nbsp; &nbsp;747 41<br />
address: &nbsp; &nbsp; &nbsp;The Czech Republic<br />
phone: &nbsp; &nbsp; &nbsp; &nbsp;+420 653 918371<br />
fax-no: &nbsp; &nbsp; &nbsp; +420 653 911791<br />
nic-hdl: &nbsp; &nbsp; &nbsp;TP231-RIPE<br />
source: &nbsp; &nbsp; &nbsp; RIPE # Filtered<br />
<br />
% Information related to '193.86.0.0/16AS2819'<br />
<br />
route: &nbsp; &nbsp; &nbsp; &nbsp;193.86.0.0/16<br />
descr: &nbsp; &nbsp; &nbsp; &nbsp;CZNET-A<br />
origin: &nbsp; &nbsp; &nbsp; AS2819<br />
mnt-by: &nbsp; &nbsp; &nbsp; GTSCZ-A-MNT<br />
source: &nbsp; &nbsp; &nbsp; RIPE # Filtered<br />
<br />
Lines containing IP:193.86.5.103 in /var/log/auth.log<br />
<br />
Feb 27 03:32:02 host sshd[21460]: Failed password for root from 193.86.5.103 port 35833 ssh2<br />
Feb 27 03:32:04 host sshd[21502]: Failed password for root from 193.86.5.103 port 36302 ssh2<br />
Feb 27 03:32:06 host sshd[21504]: Failed password for root from 193.86.5.103 port 36719 ssh2<br />
<br />
Regards,<br />
<br />
Fail2Ban</div></div>
</pre>
<p>By default fail2ban is configured to monitor SSH, which for a Proxmox host works without any additional changes. Personally I prefer a ban on 3 attempts instead of the default 6, so I have made this one change in the <em>/etc/fail2ban/jail.conf</em> file:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[ssh]<br />
maxretry = 3</div></div>
</pre>
<p>But again, the configuration file is quite well documented, so any personal preferences or modifications should be easy to accomplish.</p>
<h6 style="text-align: right;">&#8220;Online Hoodies&#8221; photo by <a href="http://www.flickr.com/photos/gwire/2981340426/" target="_blank">gwire</a>, CC Attribution License</h6>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 4641px; width: 1px; height: 1px; overflow: hidden;">
<pre>Hi,

The IP 193.86.5.103 has just been banned by Fail2Ban after
3 attempts against ssh.

Here are more information about 193.86.5.103:

% This is the RIPE Database query service.
% The objects are in RPSL format.
%
% The RIPE Database is subject to Terms and Conditions.
% See <a class="moz-txt-link-freetext" href="http://www.ripe.net/db/support/db-terms-conditions.pdf">http://www.ripe.net/db/support/db-terms-conditions.pdf</a>

% Note: This output has been filtered.
%       To receive output for a database update, use the "-B" flag.

% Information related to '193.86.4.0 - 193.86.5.255'

inetnum:      193.86.4.0 - 193.86.5.255
netname:      BRANO
descr:        BRANO, Inc.
descr:        Hradec nad Moravici
country:      CZ
admin-c:      BK230-RIPE
tech-c:       TP231-RIPE
status:       ASSIGNED PA
mnt-by:       GTSCZ-MNT
source:       RIPE # Filtered

person:       Bohumil Kriz
address:      BRANO, Inc.
address:      Computer Centre
address:      Hradec nad Moravici
address:      747 41
address:      The Czech Republic
phone:        +420 653 918118
fax-no:       +420 653 911791
nic-hdl:      BK230-RIPE
source:       RIPE # Filtered

person:       Tomas Partl
address:      Brano, Inc.
address:      Computer Centre
address:      Hradec nad Moravici
address:      747 41
address:      The Czech Republic
phone:        +420 653 918371
fax-no:       +420 653 911791
nic-hdl:      TP231-RIPE
source:       RIPE # Filtered

% Information related to '193.86.0.0/16AS2819'

route:        193.86.0.0/16
descr:        CZNET-A
origin:       AS2819
mnt-by:       GTSCZ-A-MNT
source:       RIPE # Filtered

Lines containing IP:193.86.5.103 in /var/log/auth.log

Feb 27 03:32:02 host sshd[21460]: Failed password for root from 193.86.5.103 port 35833 ssh2
Feb 27 03:32:04 host sshd[21502]: Failed password for root from 193.86.5.103 port 36302 ssh2
Feb 27 03:32:06 host sshd[21504]: Failed password for root from 193.86.5.103 port 36719 ssh2

Regards,

Fail2Ban</pre>
</div>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/&amp;title=Guide%3A+Firewall+and+router+with+Proxmox+-+Extending+its+use" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/&amp;title=Guide%3A+Firewall+and+router+with+Proxmox+-+Extending+its+use" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/&amp;title=Guide%3A+Firewall+and+router+with+Proxmox+-+Extending+its+use&amp;desc=Last%20year%20I%20wrote%20a%20guide%20on%20how%20to%20use%20Shorewall%20as%20a%20firewall%20and%20router%20for%20Proxmox.%20As%20a%20follow%20up%20I%20will%20answer%20a%20few%20questions%20I%27ve%20received%20about%20that%20guide%20that%20can%20help%20you%20extend%20its%20use.%0D%0AProxy%20ARP%0D%0AThe%20most%20common%20question%20is%20in%20regards%20to%20proxy%20ARP.%20Enabling%20this%20option%20will%20allow%20you%20t" rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/&amp;imageurl=" rel="nofollow" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/&amp;bm_description=Guide%3A+Firewall+and+router+with+Proxmox+-+Extending+its+use&amp;plugin=sexybookmarks" rel="nofollow" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/&amp;title=Guide%3A+Firewall+and+router+with+Proxmox+-+Extending+its+use" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/&amp;title=Guide%3A+Firewall+and+router+with+Proxmox+-+Extending+its+use" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/&amp;title=Guide%3A+Firewall+and+router+with+Proxmox+-+Extending+its+use" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Guide%3A+Firewall+and+router+with+Proxmox+-+Extending+its+use+-+http://bit.ly/aE9sHf&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/' rel='bookmark' title='Permanent Link: Guide: Firewall and router with Proxmox'>Guide: Firewall and router with Proxmox</a></li>
<li><a href='http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/' rel='bookmark' title='Permanent Link: Blocking w00tw00t scans'>Blocking w00tw00t scans</a></li>
<li><a href='http://www.myatus.co.uk/2009/08/24/guide-installing-opensolaris-on-a-remote-dedicated-server/' rel='bookmark' title='Permanent Link: Guide: Installing OpenSolaris on a remote dedicated server'>Guide: Installing OpenSolaris on a remote dedicated server</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Faster WP Super Cache with NginX</title>
		<link>http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/</link>
		<comments>http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 10:54:23 +0000</pubDate>
		<dc:creator>Myatu</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[benchmarking]]></category>
		<category><![CDATA[customization]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.myatus.co.uk/?p=333</guid>
		<description><![CDATA[A while ago my blog started to act up by randomly showing translated pages in place of the desired language. The culprit was a WordPress caching plugin (Hyper Cache) that started to misbehave with the latest upgrade. I promptly disabled it and went on a search for a replacement. As you may have read in [...]


Related posts:<ol><li><a href='http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/' rel='bookmark' title='Permanent Link: A simplified Nginx-Apache combo with WordPress support'>A simplified Nginx-Apache combo with WordPress support</a></li>
<li><a href='http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/' rel='bookmark' title='Permanent Link: NginX and Apache, but no memcached'>NginX and Apache, but no memcached</a></li>
<li><a href='http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/' rel='bookmark' title='Permanent Link: Compiling NginX on Debian / Ubuntu'>Compiling NginX on Debian / Ubuntu</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-thumbnail wp-image-336" title="Burnout!" src="http://www.myatus.co.uk/wp-content/uploads/2009/12/burnout_ford_racing_cc1-150x150.jpg" alt="Burnout!" width="150" height="150" />A while ago my blog started to act up by randomly showing translated pages in place of the desired language. The culprit was a WordPress caching plugin (Hyper Cache) that started to misbehave with the latest upgrade. I promptly disabled it and went on a search for a replacement.</p>
<p>As you may have read in one of my previous blog entries, specifically <a title="NginX and Apache, but no memcached" href="http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/" target="_self">&#8220;NginX and Apache, but no memcached&#8221;</a>, I prefer to use NginX as the front-end serving static files, and Apache as a back-end dealing with the dynamic pages. So it would be ideal if NginX could serve up static WordPress files, which is exactly what I am doing now with the help of WP Super Cache.<span id="more-333"></span></p>
<p><a title="WP Super Cache by Donncha" href="http://ocaoimh.ie/wp-super-cache/" target="_blank">WP Super Cache</a> is a rather popular plugin and converts the output generated by WordPress into a static HTML file. Installation is quick and painless, and automates a few tasks for you (or lets you know what needs to be changed on your website).</p>
<p>To make it work with a NginX front-end and Apache back-end, a few additional changes need to be made, primarily to the NginX configuration.</p>
<h3>WordPress / Apache Changes</h3>
<p>Firstly, enable  WP Super Cache into the <em>&#8220;full on&#8221;</em> setting, meaning it generates a <em>&#8220;cache&#8221;</em> and a <em>&#8220;super cache&#8221;</em>. WP Super Cache will then ask you to change the <em>.htaccess </em>file, by adding a few Rewrite Rules. In this case, we do not need those entries and we can reduce it to just the following:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># BEGIN WPSuperCache<br />
### WARNING: This is handled by NginX!<br />
# END WPSuperCache</div></div>
</pre>
<p>This will keep the plugin&#8217;s setting page from complaining about the need to configure <em>.htaccess</em>.</p>
<p>I have also enabled the <em>&#8220;Super Cache Compression&#8221;</em> option, however this is not mandatory. I choose to do this to relieve NginX from a few CPU cycles (as the HTML is already compressed then).</p>
<h3>NginX Changes</h3>
<p>Next the NginX website configuration needs to be modified. And a few of these modifications will depend on your website or needs. In my case, I  am using a separate template for the iPhone, Android and other smart phones and do not wish to use the cache for these. So I have the following entry in my NginX that will detect mobile phones:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">server {<br />
<br />
... (snip!) ...<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; # Check if it's a mobile phone<br />
&nbsp; &nbsp; &nbsp; &nbsp; set $mobile &quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ($http_user_agent ~* &quot;(2\.0 MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine\/3\.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA\/WX310K|LG\/U990|MIDP-2\.|MMEF20|MOT-V|NetFront|Newt|Nintendo Wii|Nitro|Nokia|Opera Mini|Palm|PlayStation Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian OS|SymbianOS|TS21i-10|UP\.Browser|UP\.Link|webOS|Windows CE|WinWAP|YahooSeeker\/M1A1-R2D2|NF-Browser|iPhone|iPod|Android|BlackBerry9530|G-TU915 Obigo|LGE VX|webOS|Nokia5800)&quot; ) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set $mobile &quot;M&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
... (snip!) ...</div></div>
</pre>
<p>This will set the variable <em>$mobile</em> to <em>&#8220;M&#8221;</em> if  the user-agent is from a mobile web browser. If you don&#8217;t need or want this, then you can simply leave it out of your NginX configuration.</p>
<p>We also need to modify the common <em>location</em> section. There are a number of ways to approach this, but I choose to use a number of <em>&#8220;if&#8221;</em> statements to build a variable <em>$wpsc_flags</em>. Depending on the list of <em>&#8220;if&#8221;</em> statements NginX will output the static cached file from WP Super Cache or continue to the Apache back-end (which will handle the rest).</p>
<p>Unfortunately NginX does not provide support for nested <em>&#8220;if&#8221;</em> statements or booleans, so this is a slightly dirty hack:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;location / {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # If it's a POST request, send it directly backend:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($request_method = POST) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; access_log &nbsp; &nbsp; &nbsp;off;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; proxy_pass &nbsp; &nbsp; &nbsp;http://apache_backend;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Is it a mobile user?<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set $wpsc_flags &quot;${mobile}&quot;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Is the user logged in?<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($http_cookie ~* &quot;(comment_author_|wordpress_logged_in_|wp-postpass_)&quot; ) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set $wpsc_flags &quot;${wpsc_flags}C&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Do we have query arguments?<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($is_args) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set $wpsc_flags &quot;${wpsc_flags}Q&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Does the (gzip) Super Cache exist?<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (-f $document_root/wp-content/cache/supercache/$host/$uri/index.html.gz) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # The file exists in the WP Super Cache<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set $wpsc_flags &quot;${wpsc_flags}F&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # If the following flags are set (in this order) we use the cached version:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($wpsc_flags = &quot;F&quot;) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expires &nbsp; &nbsp; &nbsp; &nbsp; 1h;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rewrite ^(.*)$ /wp-content/cache/supercache/$host/$uri/index.html.gz break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Or else it goes to the backend:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; access_log &nbsp; &nbsp; &nbsp;off;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; proxy_pass &nbsp; &nbsp; &nbsp;http://apache_backend;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</div></div>
</pre>
<p>By reading the comments it should be clear what this does, but I&#8217;ll clarify further just in case.</p>
<p>A HTTP POST should not be cached, and so it will be sent directly to the Apache back-end server(s) and stops doing any other checking.</p>
<p>In the next step, it creates a <em>$wpsc_flags</em> variable based on the <em>$mobile</em> variable we created earlier. If you do not use the <em>$mobile</em> variable, then you can simply replace it as following:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">set $wpsc_flags &quot;&quot;;</div></div>
</pre>
<p>Then it will add flags to <em>$wpsc_flags</em> depending on whether the current user is logged in, if the request contains arguments (ie.: <em>&#8220;someurl.com?this=is&amp;an=argument&#8221;</em>). This will prevent an editor or commenter from being presented cached pages, which can be bothersome.</p>
<p>Now, as I had turned on the <em>&#8220;Super Cache Compression&#8221;</em> in the WordPress plugin, I am looking for files that end with <em>&#8220;.html.gz&#8221;</em>. If you are not using the compression option, simply remove the <em>&#8220;.gz&#8221;</em> from the <em>&#8220;if (-f&#8221;</em> statement as well as the <em>&#8220;rewrite&#8221;</em> statement.</p>
<p>Also note that it will only display the cached data if, and only if, <em>$wpcs_flags</em> is set to &#8220;F&#8221;. If you were logged in, this variable would actually be <em>&#8220;CF&#8221;</em> (in this order!) and so it will continue to the portion where everything is sent to the Apache back-end.</p>
<h3>Speed Improvements</h3>
<p>A while ago I had posted a message on a forum that showed how a WordPress cache could improve responsiveness. The (truncated) results of a simple <em>&#8220;ab -n 1000 -c 50 http://&lt;website&gt;&#8221;</em> (ApacheBench) showed the following back then:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Requests per second: &nbsp; &nbsp;1753.08 [#/sec] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 28.521 [ms] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 0.570 [ms] (mean, across all concurrent requests)</div></div>
</pre>
<p>The cached responses were generated by Hyper Cache at the Apache back-end, then forwarded to NginX to be delivered to the user (&#8220;ab&#8221; in this case).</p>
<p>With the new setup, where NginX is responsible for the delivery of a cached response opposed to Apache / WordPress:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Requests per second: &nbsp; &nbsp;4712.65 [#/sec] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 10.610 [ms] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 0.212 [ms] (mean, across all concurrent requests)</div></div>
</pre>
<p>Although these are not conclusive, lab-certified benchmarks, the crude test does show a rather impressive improvement. The time for each request has been reduced by more than half. So it&#8217;s well worth the effort.</p>
<p><span style="color: #999999;"><a title="Ashley Force by Ford Racing" href="http://www.flickr.com/photos/26429107@N03/2508276313/in/set-72157605302725246/" target="_blank">Photo &#8220;Ashley Force&#8221; by Ford Racing (CC)</a></span></p>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/&amp;title=Faster+WP+Super+Cache+with+NginX" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/&amp;title=Faster+WP+Super+Cache+with+NginX" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/&amp;title=Faster+WP+Super+Cache+with+NginX&amp;desc=A%20while%20ago%20my%20blog%20started%20to%20act%20up%20by%20randomly%20showing%20translated%20pages%20in%20place%20of%20the%20desired%20language.%20The%20culprit%20was%20a%20Wordpress%20caching%20plugin%20%28Hyper%20Cache%29%20that%20started%20to%20misbehave%20with%20the%20latest%20upgrade.%20I%20promptly%20disabled%20it%20and%20went%20on%20a%20search%20for%20a%20replacement.%0D%0A%0D%0AAs%20you%20may%20have%20r" rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/&amp;imageurl=" rel="nofollow" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/&amp;bm_description=Faster+WP+Super+Cache+with+NginX&amp;plugin=sexybookmarks" rel="nofollow" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/&amp;title=Faster+WP+Super+Cache+with+NginX" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/&amp;title=Faster+WP+Super+Cache+with+NginX" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/&amp;title=Faster+WP+Super+Cache+with+NginX" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Faster+WP+Super+Cache+with+NginX+-+http://bit.ly/5soiQm&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/' rel='bookmark' title='Permanent Link: A simplified Nginx-Apache combo with WordPress support'>A simplified Nginx-Apache combo with WordPress support</a></li>
<li><a href='http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/' rel='bookmark' title='Permanent Link: NginX and Apache, but no memcached'>NginX and Apache, but no memcached</a></li>
<li><a href='http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/' rel='bookmark' title='Permanent Link: Compiling NginX on Debian / Ubuntu'>Compiling NginX on Debian / Ubuntu</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>DNS performance benchmarking update</title>
		<link>http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/</link>
		<comments>http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 23:36:09 +0000</pubDate>
		<dc:creator>Myatu</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.myatus.co.uk/?p=299</guid>
		<description><![CDATA[A few days ago I posted a short blog about DNS performance benchmarking by Google using namebench. After the rather surprising results, I decided to replace the primary upstream DNS server with OpenDNS. Once I had run the namebench too again, the results were showing a huge leap in performance. But strikingly, BT&#8217;s DNS servers [...]


Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/' rel='bookmark' title='Permanent Link: DNS performance benchmarking by Google'>DNS performance benchmarking by Google</a></li>
<li><a href='http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/' rel='bookmark' title='Permanent Link: NginX and Apache, but no memcached'>NginX and Apache, but no memcached</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>A few days ago I posted a short blog about <a title="DNS performance benchmarking by Google" href="http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/" target="_self">DNS performance benchmarking by Google</a> using <a title="Google namebench" href="http://google-opensource.blogspot.com/2009/12/introducing-namebench.html" target="_blank">namebench</a>. After the rather surprising results, I decided to replace the primary upstream DNS server with OpenDNS.</p>
<p>Once I had run the namebench too again, the results were showing a huge leap in performance. But strikingly, BT&#8217;s DNS servers were still faster than my own local servers. Jonathan, the resident monkey, <a title="Comment regarding local DNS server" href="http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/#comment-25665604" target="_self">also commented</a> about this based on his own tests. It seems that there might be something amiss with the namebench tool (and I shall dutifully point this out to Google, to see what they have to say).<span id="more-299"></span></p>
<p>Nevertheless, I had run the namebench several times and it did indeed radically change from two days ago where my own service provider&#8217;s DNS servers were the upstream. Following is a chart from the last benchmark:</p>
<div id="attachment_300" class="wp-caption alignnone" style="width: 310px"><a href="http://www.myatus.co.uk/wp-content/uploads/2009/12/namebench_chart_updated.png"><img class="size-medium wp-image-300" title="Namebench Chart (Updated)" src="http://www.myatus.co.uk/wp-content/uploads/2009/12/namebench_chart_updated-300x170.png" alt="Namebench Chart (Updated)" width="300" height="170" /></a><p class="wp-caption-text">Namebench Chart (Updated)</p></div>
<p>As you can see, my primary (SYS-10.10.24.4) and secondary (SYS-10.10.31.1) are now right at the top of the chart, showing a slight slow start for the primary. Unfortunately, my service provider&#8217;s DNS server (in orange) was once again trailing everyone else in this test. In fact, it did so in all the tests.</p>
<p>Following is a chart showing the mean response times in milliseconds:</p>
<div id="attachment_301" class="wp-caption alignnone" style="width: 310px"><a href="http://www.myatus.co.uk/wp-content/uploads/2009/12/namebench_mean_updated.png"><img class="size-medium wp-image-301" title="Mean Response Times (Updated)" src="http://www.myatus.co.uk/wp-content/uploads/2009/12/namebench_mean_updated-300x83.png" alt="Mean Response Times (Updated)" width="300" height="83" /></a><p class="wp-caption-text">Mean Response Times (Updated)</p></div>
<p>And this (chart) is the odd part. You would expect that a server on the same network, solely used for DNS and with less than 5% average usage, would perform better than any external server once the DNS responses have been cached.</p>
<p>While the primary DNS server is now faster than the poor performing DNS server of my service provider, it is still lagging behind BT and even Google&#8217;s public DNS servers. I am curious to know about its cause!</p>
<p>In all, namedbench reported that my primary server is 89.7% slower than &#8220;BT-30 GB&#8221;. Up from the 274.4% a few days ago &#8211; an improvement indeed!</p>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/&amp;title=DNS+performance+benchmarking+update" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/&amp;title=DNS+performance+benchmarking+update" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/&amp;title=DNS+performance+benchmarking+update&amp;desc=A%20few%20days%20ago%20I%20posted%20a%20short%20blog%20about%20DNS%20performance%20benchmarking%20by%20Google%20using%20namebench.%20After%20the%20rather%20surprising%20results%2C%20I%20decided%20to%20replace%20the%20primary%20upstream%20DNS%20server%20with%20OpenDNS.%0D%0A%0D%0AOnce%20I%20had%20run%20the%20namebench%20too%20again%2C%20the%20results%20were%20showing%20a%20huge%20leap%20in%20performance.%20B" rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/&amp;imageurl=" rel="nofollow" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/&amp;bm_description=DNS+performance+benchmarking+update&amp;plugin=sexybookmarks" rel="nofollow" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/&amp;title=DNS+performance+benchmarking+update" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/&amp;title=DNS+performance+benchmarking+update" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/&amp;title=DNS+performance+benchmarking+update" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=DNS+performance+benchmarking+update+-+http://bit.ly/5Jm9uZ&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/' rel='bookmark' title='Permanent Link: DNS performance benchmarking by Google'>DNS performance benchmarking by Google</a></li>
<li><a href='http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/' rel='bookmark' title='Permanent Link: NginX and Apache, but no memcached'>NginX and Apache, but no memcached</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DNS performance benchmarking by Google</title>
		<link>http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/</link>
		<comments>http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 11:26:37 +0000</pubDate>
		<dc:creator>Myatu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[benchmarking]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://www.myatus.co.uk/?p=277</guid>
		<description><![CDATA[Today I came across namebench by Google, a DNS (domain name system) benchmarking tool and gave it a try.  To my surprise, namebench determined that a DNS server owned by BT and located in the UK was faster than my own or my provider&#8217;s DNS servers, both of which are located in France. In fact, [...]


Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/' rel='bookmark' title='Permanent Link: DNS performance benchmarking update'>DNS performance benchmarking update</a></li>
<li><a href='http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/' rel='bookmark' title='Permanent Link: Blocking w00tw00t scans'>Blocking w00tw00t scans</a></li>
<li><a href='http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/' rel='bookmark' title='Permanent Link: Faster WP Super Cache with NginX'>Faster WP Super Cache with NginX</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Today I came across <a title="Google Namebench" href="http://google-opensource.blogspot.com/2009/12/introducing-namebench.html" target="_blank">namebench</a> by Google, a DNS (<a title="DNS Wikipedia entry" href="http://en.wikipedia.org/wiki/Domain_Name_System" target="_blank">domain name system</a>) benchmarking tool and gave it a try.  To my surprise, namebench determined that a DNS server owned by <a title="British Telecom" href="http://www.bt.com" target="_blank">BT</a> and located in the UK was faster than my own or my provider&#8217;s DNS servers, both of which are located in France.</p>
<p>In fact, this is the damning message that namebench gave me:<span id="more-277"></span></p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">namebench 1.0.5 - data/alexa-top-10000-global.txt (weighted) on 2009-12-12 09:15:57.450225<br />
threads=40 tests=200 runs=1 timeout=2.0 health_timeout=4.0 servers=10<br />
------------------------------------------------------------------------------<br />
<br />
... (snip!) ...<br />
<br />
********************************************************************************<br />
In this test, BT-70 GB is 274.4% faster than your current primary DNS server<br />
********************************************************************************</div></div>
</pre>
<p>Yikes!</p>
<p>Follwing is a chart generated by the data generated by namebench (click on it to enlarge). My primary DNS server is represented by SYS-10.10.24.4 (cyan) and secondary by SYS-10.10.31.1. (yellow). My service provider is SYS-213.186.33.9 (purple):</p>
<div id="attachment_282" class="wp-caption alignnone" style="width: 310px"><a href="http://www.myatus.co.uk/wp-content/uploads/2009/12/namebench_chart.png"><img class="size-medium wp-image-282 " title="Namebench Chart" src="http://www.myatus.co.uk/wp-content/uploads/2009/12/namebench_chart-300x170.png" alt="Namebench Chart" width="300" height="170" /></a><p class="wp-caption-text">Namebench Chart</p></div>
<p>The primary server is accessible internally only, powered by <a title="Bind9 Website" href="http://www.bind9.net" target="_blank">BIND9</a> in a typical split DNS setup. It provides the local names of internal servers (which may be different from public names) and it will cache responses for external servers (like www.google.com) through the upstream server, which are the DNS servers owned by my service provider.</p>
<p>As this and the chart below will show, the response times of my service provider&#8217;s DNS serer are rather poor. This directly correlates to a poor performance on my own primary DNS server:</p>
<div id="attachment_285" class="wp-caption alignnone" style="width: 310px"><a href="http://www.myatus.co.uk/wp-content/uploads/2009/12/namebench_mean_response_chart.png"><img class="size-medium wp-image-285" title="Mean Response Times" src="http://www.myatus.co.uk/wp-content/uploads/2009/12/namebench_mean_response_chart-300x75.png" alt="Mean Response Times" width="300" height="75" /></a><p class="wp-caption-text">Mean Response Times</p></div>
<p>My secondary DNS server, powered by <a title="PowerDNS Website" href="http://www.powerdns.org" target="_blank">PowerDNS</a>, is publicly accessible. However, on the public side it will only answer requests directly related to servers I own. Internally, it will also do this and cache responses for other external servers I do not own. The upstream DNS server is <a title="OpenDNS Website" href="http://www.opendns.com" target="_blank">OpenDNS</a>.</p>
<p>In the first namebench chart you can see how well my secondary DNS server is performing. But strangely enough, BT&#8217;s &#8220;BT-70&#8243; DNS server is providing an even better performance, particularly in response times as shown in the second chart. Because of this, namebench came to this final conclusion:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Recommended configuration (fastest + nearest):<br />
----------------------------------------------<br />
nameserver 62.6.40.162 &nbsp; &nbsp; # BT-70 GB<br />
nameserver 10.10.24.4 &nbsp; &nbsp; &nbsp;# SYS-10.10.24.4<br />
nameserver 10.10.31.1 &nbsp; &nbsp; &nbsp;# SYS-10.10.31.1 &nbsp;NXDOMAIN Hijacking</div></div>
</pre>
<p>In other words, I should move my current primary and secondary servers a position down, and use BT&#8217;s DNS server as the primary instead. <em>(A note the &#8220;NXDOMAIN Hijacking&#8221;, which is <a title="DNS hijacking" href="http://en.wikipedia.org/wiki/DNS_hijacking" target="_blank">explained here</a>, I do not practice in this behaviour!)</em></p>
<p>Despite the fact I was unaware of the overall poor quality of my provider&#8217;s DNS servers until now, I will actually keep the primary and secondary servers in their current position. Instead I will be replacing the primary upstream DNS server with OpenDNS (which is currently the case for my secondary server) or with BT&#8217;s &#8220;BT-70&#8243;. This will depend on its uptime of BT-70, comparing it to OpenDNS&#8217; uptime of 99.98% according to my own monitors.</p>
<p>In all, I must say that the new namebench tool is an instant hit. It even picked up on two errors that I can now correct. All the previous &#8220;DNS checkers&#8221; I have used, commercial or free, failed to pick up on these. Excellent!</p>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/&amp;title=DNS+performance+benchmarking+by+Google" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/&amp;title=DNS+performance+benchmarking+by+Google" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/&amp;title=DNS+performance+benchmarking+by+Google&amp;desc=Today%20I%20came%20across%20namebench%20by%20Google%2C%20a%20DNS%20%28domain%20name%20system%29%20benchmarking%20tool%20and%20gave%20it%20a%20try.%20%C2%A0To%20my%20surprise%2C%20namebench%20determined%20that%20a%20DNS%20server%20owned%20by%20BT%20and%20located%20in%20the%20UK%20was%20faster%20than%20my%20own%20or%20my%20provider%27s%20DNS%20servers%2C%20both%20of%20which%20are%20located%20in%20France.%0D%0A%0D%0AIn%20fact%2C%20th" rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/&amp;imageurl=" rel="nofollow" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/&amp;bm_description=DNS+performance+benchmarking+by+Google&amp;plugin=sexybookmarks" rel="nofollow" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/&amp;title=DNS+performance+benchmarking+by+Google" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/&amp;title=DNS+performance+benchmarking+by+Google" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/&amp;title=DNS+performance+benchmarking+by+Google" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=DNS+performance+benchmarking+by+Google+-+http://bit.ly/60ebhq&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/12/14/dns-performance-benchmarking-update/' rel='bookmark' title='Permanent Link: DNS performance benchmarking update'>DNS performance benchmarking update</a></li>
<li><a href='http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/' rel='bookmark' title='Permanent Link: Blocking w00tw00t scans'>Blocking w00tw00t scans</a></li>
<li><a href='http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/' rel='bookmark' title='Permanent Link: Faster WP Super Cache with NginX'>Faster WP Super Cache with NginX</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.myatus.co.uk/2009/12/12/dns-performance-benchmarking-by-google/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Quick Debian/Ubuntu networking tips</title>
		<link>http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/</link>
		<comments>http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 23:06:14 +0000</pubDate>
		<dc:creator>Myatu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.myatus.co.uk/?p=216</guid>
		<description><![CDATA[Like anyone else, at times I forget how to do certain things when it comes to networking. Here are a few reminders / tips specific to Debian and Ubuntu. IPv4 Specific Enable Proxy ARP (Address Resolution Protocol) Assuming eth0 as the interface, in /etc/network/interfaces add: iface eth0 inet static &#160; &#160; ... &#160; &#160; post_up [...]


Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/' rel='bookmark' title='Permanent Link: Compiling NginX on Debian / Ubuntu'>Compiling NginX on Debian / Ubuntu</a></li>
<li><a href='http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/' rel='bookmark' title='Permanent Link: Guide: Firewall and router with Proxmox'>Guide: Firewall and router with Proxmox</a></li>
<li><a href='http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/' rel='bookmark' title='Permanent Link: Blocking w00tw00t scans'>Blocking w00tw00t scans</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="size-thumbnail wp-image-228 alignleft" title="Quick Debian/Ubuntu networking tips" src="http://www.myatus.co.uk/wp-content/uploads/2009/10/iptables-150x84.PNG" alt="Quick Debian/Ubuntu networking tips" width="150" height="84" /></p>
<p>Like anyone else, at times I forget how to do certain things when it comes to networking.</p>
<p>Here are a few reminders / tips specific to Debian and Ubuntu.</p>
<p><span id="more-216"></span></p>
<h2><span>IPv4 Specific</span></h2>
<h3>Enable Proxy ARP (<a title="Address Resolution Protocol" rel="wikipedia" href="http://en.wikipedia.org/wiki/Address_Resolution_Protocol" target="_blank">Address Resolution Protocol</a>)</h3>
<p>Assuming <em>eth0</em> as the interface, in <em>/etc/network/interfaces</em> add:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iface eth0 inet static<br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; post_up echo 1 &gt; /proc/sys/net/ipv4/conf/eth0/proxy_arp</div></div>
</pre>
<h3>Route incoming traffic to another server</h3>
<p>In other words, all traffic arriving at a certain IP should be forwarded to another server (public or internal).</p>
<p>Using <em>iptables</em>, issue the following command from the shell:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-I</span> PREROUTING <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">&lt;</span>original ip<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #660033;">-j</span> DNAT <span style="color: #660033;">--to</span> <span style="color: #000000; font-weight: bold;">&lt;</span>other server<span style="color: #000000; font-weight: bold;">&gt;</span></div></div>
</pre>
<p>Where <em>&lt;original ip&gt;</em> is the IP where incoming traffic is  received, and <em>&lt;other server&gt;</em> is where the traffic should be routed to.</p>
<h3>Route outgoing web traffic via another IP</h3>
<p>In other words, make outgoing web traffic appear as if coming from another public IP address (registered to the server and router).</p>
<p>Assuming that <em>eth0</em> is the public interface, using <em>iptables</em> issue the following command from the shell:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> POSTROUTING <span style="color: #660033;">-o</span> eth0 <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> SNAT <span style="color: #660033;">--to-source</span> <span style="color: #000000; font-weight: bold;">&lt;</span>ip<span style="color: #000000; font-weight: bold;">&gt;</span></div></div>
</pre>
<p>Where <em>&lt;ip&gt;</em> is the IP address to be used.</p>
<p><em>Note: You can substitute tcp for udp, or use a different port for other applications such as FTP. Also, the IP must be routable to your server. </em></p>
<h3>Viewing the NAT table</h3>
<p>Issue the following command from the shell:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-L</span></div></div>
</pre>
<h3>Flush iptables</h3>
<p>The clear the <em>iptables</em> entirely,  issue the following command from the shell:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iptables <span style="color: #660033;">-F</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-F</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> iptables <span style="color: #660033;">-t</span> mangle <span style="color: #660033;">-F</span></div></div>
</pre>
<h2><span>IPv6 Specific</span></h2>
<h3>Enable Proxy NDP for IPv6 (Neighbor Detection Protocol)</h3>
<p>Assuming <em>eth0</em> as the interface, in <em>/etc/network/interfaces</em> add:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iface eth0 inet static<br />
&nbsp;...<br />
&nbsp;post_up echo 1 &gt; /proc/sys/net/ipv6/conf/eth0/proxy_ndp</div></div>
</pre>
<h3>Manually announce an IPv6 neighbor</h3>
<p>Assuming eth0 as the public IPv6 interface:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ip <span style="color: #660033;">-6</span> neigh add proxy <span style="color: #000000; font-weight: bold;">&lt;</span>ipv6<span style="color: #000000; font-weight: bold;">&gt;</span> dev eth0</div></div>
</pre>
<p>Where <em>&lt;ipv6&gt;</em> is the actual IPv6 address.</p>
<h3>Enable IPv6 forwarding</h3>
<p>In <em>/etc/sysctl.conf</em> uncomment:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">net.ipv6.conf.all.forwarding=1</div></div>

<em> </em></pre>
<h3>Adding more than one IPv6 address per interface</h3>
<p>Edit <em>/etc/network/interfaces</em>, add:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iface eth0 inet6 static<br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; up /sbin/ifconfig eth0 inet6 add &lt;ip&gt;/&lt;netmask&gt;</div></div>
</pre>
<p>Where <em>&lt;ip&gt;/&lt;netmask&gt;</em> is the actual IPv6 and netmask respectively, i.e.: <em>dead:beef:cafe:1::1/64</em>.</p>
<p><em>Note:  The last entry takes priority.</em></p>
<h3>Setup a 6to4 tunnel (IPv6 to IPv4 translation)</h3>
<p>Obtain IPv6 address for 6to4:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">printf</span> <span style="color: #ff0000;">&quot;2002:%02x%02x:%02x%02x::1<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">&lt;</span>ipv4<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> . <span style="color: #ff0000;">' '</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></div></div>
</pre>
<p>Where <em>&lt;ipv4&gt;</em> is the actual IPv4 address, i.e.., <em>91.2.3.4</em> would result in <em>2002:5b02:0304::1</em>.</p>
<p>Edit <em>/etc/network/interfaces</em>, add:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">auto tun6to4<br />
iface tun6to4 inet6 v4tunnel<br />
&nbsp; &nbsp; address &lt;ipv6 obtained&gt;<br />
&nbsp; &nbsp; netmask 16<br />
&nbsp; &nbsp; gateway ::192.88.99.1<br />
&nbsp; &nbsp; endpoint any<br />
&nbsp; &nbsp; local &lt;actual ipv4&gt;</div></div>
</pre>
<p>Where the &lt;ipv6 obtained&gt; and &lt;actual ipv4&gt; is from the explanation given earlier. For example:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">auto tun6to4<br />
iface tun6to4 inet6 v4tunnel<br />
&nbsp; &nbsp; address 2002:5b02:0304::1<br />
&nbsp; &nbsp; netmask 16<br />
&nbsp; &nbsp; gateway ::192.88.99.1<br />
&nbsp; &nbsp; endpoint any<br />
&nbsp; &nbsp; local 91.2.3.4</div></div>
</pre>
<p><em>Note: 192.88.99.1 will automatically select the nearest IPv6 to IPv4 gateway.</em></p>
<h2><span>Application Specific</span></h2>
<h3>Setup OpenVPN tap tunnel interface on a bridge</h3>
<p>Edit <em>/etc/network/interfaces</em>, add:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">iface vmbr0 inet static<br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; bridge_ports tap0<br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; pre-up /usr/sbin/openvpn --mktun --dev tap0<br />
&nbsp; &nbsp; post-down /usr/sbin/openvpn --rmtun --dev tap0</div></div>
</pre>
<h4>Enable OpenVZ/Proxmox for IPv6</h4>
<p>Edit <em>/etc/vz/vz.conf</em> and change:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">...<br />
IPV6=&quot;yes&quot;<br />
...</div></div>
</pre>
<h3>Adding a failover IP (OVH)</h3>
<p>Edit <em>/etc/network/interfaces</em> and add a new alias:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">auto eth0:&lt;alias number&gt;<br />
iface eth0:&lt;alias number&gt; inet static<br />
&nbsp; &nbsp; address &nbsp;&lt;failover ip&gt;<br />
&nbsp; &nbsp; netmask &nbsp;255.255.255.255</div></div>
</pre>
<p>Where <em>&lt;alias number&gt; </em>is a sequential number starting at 0 (zero) and <em>&lt;failover ip&gt;</em> is the actual failover IP address. For example:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">auto eth0:0<br />
iface eth0:0 inet static<br />
&nbsp; &nbsp; address &nbsp;91.2.3.4<br />
&nbsp; &nbsp; netmask &nbsp;255.255.255.255</div></div>
</pre>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/&amp;title=Quick+Debian%2FUbuntu+networking+tips" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/&amp;title=Quick+Debian%2FUbuntu+networking+tips" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/&amp;title=Quick+Debian%2FUbuntu+networking+tips&amp;desc=%0D%0A%0D%0ALike%20anyone%20else%2C%20at%20times%20I%20forget%20how%20to%20do%20certain%20things%20when%20it%20comes%20to%20networking.%0D%0A%0D%0AHere%20are%20a%20few%20reminders%20%2F%20tips%20specific%20to%20Debian%20and%20Ubuntu.%0D%0A%0D%0A%0D%0AIPv4%20Specific%0D%0AEnable%20Proxy%20ARP%20%28Address%20Resolution%20Protocol%29%0D%0AAssuming%20eth0%20as%20the%20interface%2C%20in%20%2Fetc%2Fnetwork%2Finterfaces%20add%3A%0D%0A%5Bcce_te" rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/&amp;imageurl=" rel="nofollow" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/&amp;bm_description=Quick+Debian%2FUbuntu+networking+tips&amp;plugin=sexybookmarks" rel="nofollow" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/&amp;title=Quick+Debian%2FUbuntu+networking+tips" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/&amp;title=Quick+Debian%2FUbuntu+networking+tips" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/&amp;title=Quick+Debian%2FUbuntu+networking+tips" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Quick+Debian%2FUbuntu+networking+tips+-+http://bit.ly/zaDfP&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/' rel='bookmark' title='Permanent Link: Compiling NginX on Debian / Ubuntu'>Compiling NginX on Debian / Ubuntu</a></li>
<li><a href='http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/' rel='bookmark' title='Permanent Link: Guide: Firewall and router with Proxmox'>Guide: Firewall and router with Proxmox</a></li>
<li><a href='http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/' rel='bookmark' title='Permanent Link: Blocking w00tw00t scans'>Blocking w00tw00t scans</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Compiling NginX on Debian / Ubuntu</title>
		<link>http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/</link>
		<comments>http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 19:37:01 +0000</pubDate>
		<dc:creator>Myatu</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[customization]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.myatus.co.uk/?p=185</guid>
		<description><![CDATA[I really like the efficiency and simplicity of the NginX web server (pron.: &#8220;Engine X&#8221;). In one of my previous blurbs, &#8220;NginX and Apache, but no memcached&#8221;, I gave some numbers on how well it performed on a no-frills server. For Debian and Ubuntu users installing NginX couldn&#8217;t be easier. Simply issue the command  apt-get [...]


Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/' rel='bookmark' title='Permanent Link: Quick Debian/Ubuntu networking tips'>Quick Debian/Ubuntu networking tips</a></li>
<li><a href='http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/' rel='bookmark' title='Permanent Link: A simplified Nginx-Apache combo with WordPress support'>A simplified Nginx-Apache combo with WordPress support</a></li>
<li><a href='http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/' rel='bookmark' title='Permanent Link: Faster WP Super Cache with NginX'>Faster WP Super Cache with NginX</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I really like the efficiency and simplicity of the <a title="NginX Website" href="http://www.nginx.net" target="_blank">NginX</a> web server (pron.: &#8220;Engine X&#8221;). In one of my previous blurbs, <a href="http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/" target="_self">&#8220;NginX and Apache, but no memcached&#8221;</a>, I gave some numbers on how well it performed on a no-frills server.</p>
<p>For Debian and Ubuntu users installing NginX couldn&#8217;t be easier. Simply issue the command  <em>apt-get install nginx</em> command and do some basic configuration.</p>
<p>However, the version availble in the Debian and Ubuntu&#8217;s package repositories has not been compiled with IPv6 support. If you need this, or if you prefer to use bleeding-edge technology, then compiling NginX is the solution.<span id="more-185"></span></p>
<p>Personally I prefer to install NginX from the Debian/Ubuntu package repository before I compile the source code from NginX; this so that I have the proper directory layouts and an official init script. If you prefer a pure source code install, then not to worry as this will cover both.</p>
<h3>Required library packages</h3>
<p>Other than the compiler you also need a few libraries installed, such as the zlib and libssl. The required libraries and the compiler can be obtained with the following command:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> build-essential libc6 libpcre3 libpcre3-dev libpcrecpp0 libssl0.9.8 libssl-dev zlib1g zlib1g-dev lsb-base</div></div>
</pre>
<h3>Obtain the latest source code</h3>
<p>Be sure to check <a title="NginX Website" href="http://www.nginx.net" target="_blank">NginX&#8217;s official website</a> for the latest stable version  of NginX, currently 0.7.61. Download it using the following command:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>sysoev.ru<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx-0.7.61.tar.gz <span style="color: #660033;">-P</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src</div></div>
</pre>
<p>This will place the file in the <em>/usr/src</em> directory. Let&#8217;s untar it:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<br />
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvf</span> nginx-0.7.61.tar.gz<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> nginx-0.7.61</div></div>
</pre>
<h3>Configure NginX compilate-time options</h3>
<p>To see which compile-time options are available, type</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--help</span></div></div>
</pre>
<p>The configuration I prefer to use keeps in line with Debian / Ubuntu&#8217;s default directory layouts, provides support for IPv6, SSL (<em>https://</em>), WebDAV and Streaming FLV:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--sbin-path</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin <span style="color: #660033;">--conf-path</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf \<br />
&nbsp;<span style="color: #660033;">--error-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>error.log <span style="color: #660033;">--pid-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>nginx.pid \<br />
&nbsp;<span style="color: #660033;">--lock-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>nginx.lock <span style="color: #660033;">--http-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>access.log \<br />
&nbsp;<span style="color: #660033;">--http-client-body-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>body \<br />
&nbsp;<span style="color: #660033;">--http-proxy-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>proxy \<br />
&nbsp;<span style="color: #660033;">--http-fastcgi-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>fastcgi <span style="color: #660033;">--with-debug</span> \<br />
&nbsp;--with-http_stub_status_module --with-http_flv_module --with-http_ssl_module \<br />
&nbsp;--with-http_dav_module <span style="color: #660033;">--with-ipv6</span></div></div>
</pre>
<p>This will display various &#8220;checking&#8221; messages, but the important bit is that it reaches the following summary:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Configuration summary<br />
&nbsp;+ using system PCRE library<br />
&nbsp;+ using system OpenSSL library<br />
&nbsp;+ md5: using OpenSSL library<br />
&nbsp;+ sha1 library is not used<br />
&nbsp;+ using system zlib library<br />
<br />
&nbsp;nginx path prefix: &quot;/usr/local/nginx&quot;<br />
&nbsp;nginx binary file: &quot;/usr/sbin&quot;<br />
&nbsp;nginx configuration prefix: &quot;/etc/nginx&quot;<br />
&nbsp;nginx configuration file: &quot;/etc/nginx/nginx.conf&quot;<br />
&nbsp;nginx pid file: &quot;/var/run/nginx.pid&quot;<br />
&nbsp;nginx error log file: &quot;/var/log/nginx/error.log&quot;<br />
&nbsp;nginx http access log file: &quot;/var/log/nginx/access.log&quot;<br />
&nbsp;nginx http client request body temporary files: &quot;/var/lib/nginx/body&quot;<br />
&nbsp;nginx http proxy temporary files: &quot;/var/lib/nginx/proxy&quot;<br />
&nbsp;nginx http fastcgi temporary files: &quot;/var/lib/nginx/fastcgi&quot;</div></div>
</pre>
<h3>Compile and install NginX</h3>
<p>You are now ready to compile and install NginX by issuing the following commands:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></div></div>
</pre>
<p>If all everything compiled without error, you should be able to type the command:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nginx <span style="color: #660033;">-v</span></div></div>
</pre>
<p>And the result would be:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nginx version: nginx<span style="color: #000000; font-weight: bold;">/</span>0.7.61</div></div>
</pre>
<p>If you have installed NginX through the Debian or Ubuntu package repositories prior, you will need to restart NginX:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx restart</div></div>
</pre>
<p>However, if you are using a source-only install then you would likely need the init script as well. Following is the init script courtesy <a title="Debian Website" href="http://www.debian.org" target="_blank">Debian</a>, which you need to create at <em>/etc/init.d/nginx</em> :</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#! /bin/sh<br />
<br />
### BEGIN INIT INFO<br />
# Provides: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nginx<br />
# Required-Start: &nbsp; &nbsp;$all<br />
# Required-Stop: &nbsp; &nbsp; $all<br />
# Default-Start: &nbsp; &nbsp; 2 3 4 5<br />
# Default-Stop: &nbsp; &nbsp; &nbsp;0 1 6<br />
# Short-Description: starts the nginx web server<br />
# Description: &nbsp; &nbsp; &nbsp; starts nginx using start-stop-daemon<br />
### END INIT INFO<br />
<br />
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin<br />
DAEMON=/usr/sbin/nginx<br />
NAME=nginx<br />
DESC=nginx<br />
<br />
test -x $DAEMON || exit 0<br />
<br />
# Include nginx defaults if available<br />
if [ -f /etc/default/nginx ] ; then<br />
&nbsp; &nbsp; &nbsp; &nbsp; . /etc/default/nginx<br />
fi<br />
<br />
set -e<br />
<br />
case &quot;$1&quot; in<br />
&nbsp; start)<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo -n &quot;Starting $DESC: &quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --exec $DAEMON -- $DAEMON_OPTS || true<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo &quot;$NAME.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ;;<br />
&nbsp; stop)<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo -n &quot;Stopping $DESC: &quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --exec $DAEMON || true<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo &quot;$NAME.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ;;<br />
&nbsp; restart|force-reload)<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo -n &quot;Restarting $DESC: &quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; start-stop-daemon --stop --quiet --pidfile \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /var/run/$NAME.pid --exec $DAEMON || true<br />
&nbsp; &nbsp; &nbsp; &nbsp; sleep 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; start-stop-daemon --start --quiet --pidfile \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo &quot;$NAME.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ;;<br />
&nbsp; reload)<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo -n &quot;Reloading $DESC configuration: &quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --exec $DAEMON || true<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo &quot;$NAME.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ;;<br />
&nbsp; configtest)<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo -n &quot;Testing $DESC configuration: &quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if nginx -t &gt; /dev/null 2&gt;&amp;1<br />
&nbsp; &nbsp; &nbsp; &nbsp; then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo &quot;$NAME.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit $?<br />
&nbsp; &nbsp; &nbsp; &nbsp; fi<br />
&nbsp; &nbsp; &nbsp; &nbsp; ;;<br />
&nbsp; *)<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo &quot;Usage: $NAME {start|stop|restart|reload|force-reload|configtest}&quot; &gt;&amp;2<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; ;;<br />
esac<br />
<br />
exit 0</div></div>
</pre>
<p>Remember to make the init script executable:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init<span style="color: #000000; font-weight: bold;">/</span>nginx</div></div>
</pre>
<p>And if you wish to start NginX automatically at boot time:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">update-rc.d nginx defaults</div></div>
</pre>
<p>All that&#8217;s left is configuring NginX in the <em>/etc/nginx/</em> directory. You can refer to the <a title="NginX Wiki" href="http://wiki.nginx.org/Main" target="_blank">NginX Wiki</a> for further assistance. Enjoy!</p>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/&amp;title=Compiling+NginX+on+Debian+%2F+Ubuntu" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/&amp;title=Compiling+NginX+on+Debian+%2F+Ubuntu" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/&amp;title=Compiling+NginX+on+Debian+%2F+Ubuntu&amp;desc=I%20really%20like%20the%20efficiency%20and%20simplicity%20of%20the%20NginX%20web%20server%20%28pron.%3A%20%22Engine%20X%22%29.%20In%20one%20of%20my%20previous%20blurbs%2C%20%22NginX%20and%20Apache%2C%20but%20no%20memcached%22%2C%20I%20gave%20some%20numbers%20on%20how%20well%20it%20performed%20on%20a%20no-frills%20server.%0D%0A%0D%0AFor%20Debian%20and%20Ubuntu%20users%20installing%20NginX%20couldn%27t%20be%20easier.%20Simply%20" rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/&amp;imageurl=" rel="nofollow" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/&amp;bm_description=Compiling+NginX+on+Debian+%2F+Ubuntu&amp;plugin=sexybookmarks" rel="nofollow" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/&amp;title=Compiling+NginX+on+Debian+%2F+Ubuntu" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/&amp;title=Compiling+NginX+on+Debian+%2F+Ubuntu" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/&amp;title=Compiling+NginX+on+Debian+%2F+Ubuntu" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Compiling+NginX+on+Debian+%2F+Ubuntu+-+http://bit.ly/96Utt&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/' rel='bookmark' title='Permanent Link: Quick Debian/Ubuntu networking tips'>Quick Debian/Ubuntu networking tips</a></li>
<li><a href='http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/' rel='bookmark' title='Permanent Link: A simplified Nginx-Apache combo with WordPress support'>A simplified Nginx-Apache combo with WordPress support</a></li>
<li><a href='http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/' rel='bookmark' title='Permanent Link: Faster WP Super Cache with NginX'>Faster WP Super Cache with NginX</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NginX and Apache, but no memcached</title>
		<link>http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/</link>
		<comments>http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 22:13:01 +0000</pubDate>
		<dc:creator>Myatu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Musings]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.myatus.co.uk/?p=144</guid>
		<description><![CDATA[I&#8217;ve been reading a few other blogs about how some people have implemented NginX as an accelerator for their Apache-based websites. NginX outperforms Apache on small- to mid-range servers when it comes to static file handling, particularly because it is event driven. The downside of NginX is that PHP can only be used with FastCGI. [...]


Related posts:<ol><li><a href='http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/' rel='bookmark' title='Permanent Link: A simplified Nginx-Apache combo with WordPress support'>A simplified Nginx-Apache combo with WordPress support</a></li>
<li><a href='http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/' rel='bookmark' title='Permanent Link: Faster WP Super Cache with NginX'>Faster WP Super Cache with NginX</a></li>
<li><a href='http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/' rel='bookmark' title='Permanent Link: Compiling NginX on Debian / Ubuntu'>Compiling NginX on Debian / Ubuntu</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been reading a few other blogs about how some people have implemented <a title="NginX Website" href="http://www.nginx.org" target="_blank">NginX</a> as an accelerator for their <a title="Apache Website" href="http://www.apache.org" target="_blank">Apache</a>-based websites.</p>
<p>NginX outperforms Apache on small- to mid-range servers when it comes to static file handling, particularly because it is event driven.</p>
<p>The downside of NginX is that PHP can only be used with FastCGI. In general, most how-to&#8217;s explain how to implement PHP FastCGI with NginX using TCP. This is adding extra overhead and slows PHP to a crawl. A better solution is to use the UNIX sockets instead, which is explained well in <a title="Till's Blog - NginX + PHP-CGI on a Socket" href="http://till.klampaeckel.de/blog/archives/51-Ubuntu-nginx+php-cgi-on-a-socket.html" target="_blank">Till&#8217;s blog</a>.</p>
<p>But even using UNIX sockets, the PHP FastCGI and NginX combination is not as fast as Apache can handle PHP requests. For this reason, NginX can act as a great accelerator for static files while Apache deals with all the PHP requests. Even with the extra TCP overhead between NginX and Apache, this makes for quite a speedy combination.</p>
<p>Thinking logically, some people figured that loading static files from RAM memory instead of the harddrive must make things even faster. But that really depends&#8230;<span id="more-144"></span></p>
<h3>Using Memcached</h3>
<p>Loading static files from RAM memory is accomplished using the <a title="Memcached Website" href="http://www.danga.com/memcached/" target="_blank">memcached</a> daemon and the NginX memcached module. Various how-to&#8217;s describe the procedure along these lines:</p>
<ul>
<li>A script that&#8217;s run at boot time, using a CRON or other method, that loads static files from the harddrive into memcached (RAM).</li>
<li>NginX is configured to load a requested file from memcached and if failed to do so, load it directly from the harddrive instead.</li>
</ul>
<p>But unfortunately the NginX memcached module is only capable of TCP communications. If memcached is located on the same server, it would have made more sense to use UNIX sockets instead (just like PHP FastCGI over UNIX sockets).</p>
<p>See, in my case there was so much overhead that NginX slowed to less than 8,000 requests per second. To put this in perspective, Apache was capable of serving 18,898 static 100-byte files per second on the same server.</p>
<p>So using memcached is only worth it if you are caching files that are spread over several back-end servers or are dynamic of nature (ie., PHP output that changes very little). Not if these files are local to NginX, especially with NginX&#8217;s highly efficient caching methods.</p>
<h3>Speedy NginX</h3>
<p>Now, how much faster is NginX compared to Apache when it comes to static files anyway? Well, I&#8217;ve have some non-definitive numbers for you, obtained on a low-range server:</p>
<p>Server:</p>
<p>Intel(R) Core(TM)2 Duo CPU     E6750  @ 2.66GHz, 2x750GB Seagate Barracuda 7200.11 32M RAID-1, 4GB RAM, Debian Lenny (5.0) i386 (2.6.24-7 Ubuntu-based, back-ported kernel)</p>
<p>Test parameters:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ab <span style="color: #660033;">-k</span> <span style="color: #660033;">-c5</span> <span style="color: #660033;">-t10000</span> http:<span style="color: #000000; font-weight: bold;">//&lt;</span>server<span style="color: #000000; font-weight: bold;">&gt;/</span><span style="color: #000000;">100</span>.html</div></div>
</pre>
<p>Apache:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Server Software: &nbsp; &nbsp; &nbsp; &nbsp;Apache/2.2.9<br />
Server Hostname: &nbsp; &nbsp; &nbsp; &nbsp;&lt;server&gt;<br />
Server Port: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;80<br />
<br />
Document Path: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/100.html<br />
Document Length: &nbsp; &nbsp; &nbsp; &nbsp;100 bytes<br />
<br />
Concurrency Level: &nbsp; &nbsp; &nbsp;5<br />
Time taken for tests: &nbsp; 2.646 seconds<br />
Complete requests: &nbsp; &nbsp; &nbsp;50000<br />
Failed requests: &nbsp; &nbsp; &nbsp; &nbsp;0<br />
Write errors: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0<br />
Keep-Alive requests: &nbsp; &nbsp;49508<br />
Total transferred: &nbsp; &nbsp; &nbsp;22577856 bytes<br />
HTML transferred: &nbsp; &nbsp; &nbsp; 5000000 bytes<br />
Requests per second: &nbsp; &nbsp;18898.08 [#/sec] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 0.265 [ms] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 0.053 [ms] (mean, across all concurrent requests)<br />
Transfer rate: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;8333.56 [Kbytes/sec] received<br />
<br />
Connection Times (ms)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; min &nbsp;mean[+/-sd] median &nbsp; max<br />
Connect: &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;0 &nbsp; 0.0 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; 0<br />
Processing: &nbsp; &nbsp; 0 &nbsp; &nbsp;0 &nbsp; 0.5 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;49<br />
Waiting: &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;0 &nbsp; 0.5 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;49<br />
Total: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;0 &nbsp; 0.5 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;49<br />
<br />
Percentage of the requests served within a certain time (ms)<br />
&nbsp; 50% &nbsp; &nbsp; &nbsp;0<br />
&nbsp; 66% &nbsp; &nbsp; &nbsp;0<br />
&nbsp; 75% &nbsp; &nbsp; &nbsp;0<br />
&nbsp; 80% &nbsp; &nbsp; &nbsp;0<br />
&nbsp; 90% &nbsp; &nbsp; &nbsp;0<br />
&nbsp; 95% &nbsp; &nbsp; &nbsp;0<br />
&nbsp; 98% &nbsp; &nbsp; &nbsp;1<br />
&nbsp; 99% &nbsp; &nbsp; &nbsp;1<br />
&nbsp;100% &nbsp; &nbsp; 49 (longest request)</div></div>
</pre>
<p>NginX:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Server Software: &nbsp; &nbsp; &nbsp; &nbsp;nginx/0.7.61<br />
Server Hostname: &nbsp; &nbsp; &nbsp; &nbsp;&lt;server&gt;<br />
Server Port: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;80<br />
<br />
Document Path: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/100.html<br />
Document Length: &nbsp; &nbsp; &nbsp; &nbsp;100 bytes<br />
<br />
Concurrency Level: &nbsp; &nbsp; &nbsp;5<br />
Time taken for tests: &nbsp; 1.928 seconds<br />
Complete requests: &nbsp; &nbsp; &nbsp;50000<br />
Failed requests: &nbsp; &nbsp; &nbsp; &nbsp;0<br />
Write errors: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0<br />
Keep-Alive requests: &nbsp; &nbsp;49502<br />
Total transferred: &nbsp; &nbsp; &nbsp;19397510 bytes<br />
HTML transferred: &nbsp; &nbsp; &nbsp; 5000000 bytes<br />
Requests per second: &nbsp; &nbsp;25937.28 [#/sec] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 0.193 [ms] (mean)<br />
Time per request: &nbsp; &nbsp; &nbsp; 0.039 [ms] (mean, across all concurrent requests)<br />
Transfer rate: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;9826.54 [Kbytes/sec] received<br />
<br />
Connection Times (ms)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; min &nbsp;mean[+/-sd] median &nbsp; max<br />
Connect: &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;0 &nbsp; 0.0 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; 0<br />
Processing: &nbsp; &nbsp; 0 &nbsp; &nbsp;0 &nbsp; 0.1 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; 5<br />
Waiting: &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;0 &nbsp; 0.1 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; 5<br />
Total: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;0 &nbsp; 0.1 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; 5<br />
<br />
Percentage of the requests served within a certain time (ms)<br />
&nbsp; 50% &nbsp; &nbsp; &nbsp;0<br />
&nbsp; 66% &nbsp; &nbsp; &nbsp;0<br />
&nbsp; 75% &nbsp; &nbsp; &nbsp;0<br />
&nbsp; 80% &nbsp; &nbsp; &nbsp;0<br />
&nbsp; 90% &nbsp; &nbsp; &nbsp;0<br />
&nbsp; 95% &nbsp; &nbsp; &nbsp;0<br />
&nbsp; 98% &nbsp; &nbsp; &nbsp;0<br />
&nbsp; 99% &nbsp; &nbsp; &nbsp;0<br />
&nbsp;100% &nbsp; &nbsp; &nbsp;5 (longest request)</div></div>
</pre>
<p>This is the setup I&#8217;m using on all the web servers I am deploying, NginX as the front-end and a number of Apache servers at the back-end to deal with non-static files, including PHP.</p>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/&amp;title=NginX+and+Apache%2C+but+no+memcached" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/&amp;title=NginX+and+Apache%2C+but+no+memcached" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/&amp;title=NginX+and+Apache%2C+but+no+memcached&amp;desc=I%27ve%20been%20reading%20a%20few%20other%20blogs%20about%20how%20some%20people%20have%20implemented%20NginX%20as%20an%20accelerator%20for%20their%20Apache-based%20websites.%0D%0A%0D%0ANginX%20outperforms%20Apache%20on%20small-%20to%20mid-range%20servers%20when%20it%20comes%20to%20static%20file%20handling%2C%20particularly%20because%20it%20is%20event%20driven.%0D%0A%0D%0AThe%20downside%20of%20NginX%20is%20t" rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/&amp;imageurl=" rel="nofollow" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/&amp;bm_description=NginX+and+Apache%2C+but+no+memcached&amp;plugin=sexybookmarks" rel="nofollow" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/&amp;title=NginX+and+Apache%2C+but+no+memcached" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/&amp;title=NginX+and+Apache%2C+but+no+memcached" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/&amp;title=NginX+and+Apache%2C+but+no+memcached" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=NginX+and+Apache%2C+but+no+memcached+-+http://bit.ly/DFn63&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.myatus.co.uk/2010/06/28/a-simplified-nginx-apache-combo-with-wordpress-support/' rel='bookmark' title='Permanent Link: A simplified Nginx-Apache combo with WordPress support'>A simplified Nginx-Apache combo with WordPress support</a></li>
<li><a href='http://www.myatus.co.uk/2009/12/17/faster-wp-super-cache-with-nginx/' rel='bookmark' title='Permanent Link: Faster WP Super Cache with NginX'>Faster WP Super Cache with NginX</a></li>
<li><a href='http://www.myatus.co.uk/2009/09/07/compiling-nginx-on-debian-ubuntu/' rel='bookmark' title='Permanent Link: Compiling NginX on Debian / Ubuntu'>Compiling NginX on Debian / Ubuntu</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.myatus.co.uk/2009/08/31/nginx-and-apache-but-no-memcached/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Guide: Firewall and router with Proxmox</title>
		<link>http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/</link>
		<comments>http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 19:43:40 +0000</pubDate>
		<dc:creator>Myatu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[proxmox]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[shorewall]]></category>

		<guid isPermaLink="false">http://www.myatus.co.uk/?p=120</guid>
		<description><![CDATA[By default Proxmox does not come with a firewall, which may leave it and your virtual servers exposed to the elements of the Internet. An additional issue arises when a hosting provider blocks servers if unauthorized MAC addresses are detected. As Proxmox&#8217;s bridged network creates and exposes MAC addresses for its virtual network interfaces, this [...]


Related posts:<ol><li><a href='http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/' rel='bookmark' title='Permanent Link: Guide: Firewall and router with Proxmox &#8211; Extending its use'>Guide: Firewall and router with Proxmox &#8211; Extending its use</a></li>
<li><a href='http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/' rel='bookmark' title='Permanent Link: Quick Debian/Ubuntu networking tips'>Quick Debian/Ubuntu networking tips</a></li>
<li><a href='http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/' rel='bookmark' title='Permanent Link: Blocking w00tw00t scans'>Blocking w00tw00t scans</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-122" title="Firewall and router with Proxmox" src="http://www.myatus.co.uk/wp-content/uploads/2009/08/hacker.jpg" alt="Firewall and router with Proxmox" width="199" height="170" />By default Proxmox does not come with a firewall, which may leave it and your virtual servers exposed to the elements of the Internet.</p>
<p>An additional issue arises when a hosting provider blocks servers if unauthorized MAC addresses are detected. As Proxmox&#8217;s bridged network creates and exposes MAC addresses for its virtual network interfaces, this may cause your server to be blocked from the hosting provider&#8217;s network.</p>
<p>To combat both this article will describe how to create your own virtual network with firewall protection using <a title="Shorewall Website" href="http://www.shorewall.net" target="_blank">Shorewall</a>, a popular and effective firewall / router software package.</p>
<p><span id="more-120"></span></p>
<h2><span>Overview</span></h2>
<div id="attachment_125" class="wp-caption alignright" style="width: 160px"><a href="http://www.myatus.co.uk/wp-content/uploads/2009/08/pmx_fw.png"><img class="size-thumbnail wp-image-125 " title="Firewall and router with Proxmox" src="http://www.myatus.co.uk/wp-content/uploads/2009/08/pmx_fw-150x150.png" alt="Firewall and router with Proxmox" width="150" height="150" /></a><p class="wp-caption-text">Figure 1.</p></div>
<p>We will be creating three separate zones, namely:</p>
<ol>
<li>The Internet (&#8220;net&#8221;);</li>
<li>The firewall / Proxmox Host Node (&#8220;fw&#8221;); and</li>
<li>The virtual network (&#8220;dmz&#8221;)</li>
</ol>
<p>All traffic from the Internet is filtered or blocked by the firewall, after which it is routed to its final destination on the virtual network or the Proxmox Host Node itself. A visual representation of this can be seen in the figure 1.</p>
<h2><span>Host Network Configuration</span></h2>
<p>Some modifications are required to your host network configuration, particularly the default <em>vmbr0</em> network interface. We will turn it into a blind bridge (without any bride ports) and assign it an IP address within the private IP range of 10.0.0.0/8 (A-Class).</p>
<h3>Determine the current network configuration</h3>
<p>Before we do this, we need to determine the current network configuration because this can be different depending on the hosting provider and other factors. Assuming that <em>eth0</em> is the network interface that connects the server to the Internet, we issue the following command:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ifconfig</span> eth0</div></div>
</pre>
<p>This will give an output similar to:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">eth0 &nbsp; &nbsp; &nbsp;Link encap:Ethernet &nbsp;HWaddr 00:ff:ff:ff:ff:ff<br />
&nbsp;inet addr:91.11.22.33 &nbsp;Bcast:91.11.22.255 &nbsp;Mask:255.255.255.0<br />
...</div></div>
</pre>
<p>It gives us the current IP address, broadcast address and netmask used by <em>eth0</em>.  One last piece of information we need is the gateway used by <em>eth0</em>, which is obtained with the follwing command:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">route <span style="color: #660033;">-n</span></div></div>
</pre>
<p>You will see an output similar to:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">...<br />
0.0.0.0 &nbsp; &nbsp; &nbsp; &nbsp; 91.11.22.254 &nbsp; &nbsp;0.0.0.0 &nbsp; &nbsp; &nbsp; &nbsp; UG &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; &nbsp;0 eth0</div></div>
</pre>
<p>The first column of 0.0.0.0 designates the default route (any traffic that has no specific route), and the second column the gateway. Now that we have obtained all this information, we can edit the <em>/etc/network/interfaces</em> file.</p>
<p>First we need to verify that <em>eth0</em> has already been defined within this file. It will look similar to:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">auto eth0<br />
iface eth0 inet static<br />
&nbsp; &nbsp; &nbsp; &nbsp; address 91.11.22.33<br />
&nbsp; &nbsp; &nbsp; &nbsp; netmask 255.255.255.0<br />
&nbsp; &nbsp; &nbsp; &nbsp; broadcast 91.11.22.255<br />
&nbsp; &nbsp; &nbsp; &nbsp; gateway 91.11.22.254<br />
<br />
...(additional stanzas)...</div></div>
</pre>
<p>Where the IPs match those you have obtained by use of the <em>ifconfig</em> and <em>route</em> commands.</p>
<p>Or if your server uses DHCP to assign the IP address then it will look similar to:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">allow-hotplug eth0<br />
iface eth0 inet dhcp<br />
<br />
...(additional stanzas)...</div></div>
</pre>
<p>If either is the case, you can skip the follow section and continue to <a href="#change_vmbr0">change the <em>vmbr0</em> network interface</a>.</p>
<h3>Updating the eth0 network interface</h3>
<p>If you have reached this section, then your <em>vmbr0</em> network interface was most likely directly bridged with your <em>eth0</em> network interface, meaning that <em>vmbr0</em> contains your public IP address, network gateway and other settings. Because we will turn <em>vmbr0</em> into a blind bridge in the next section, we need to create or edit a separate <em>eth0</em> stanza in the <em>/etc/network/interfaces</em> file first.</p>
<p>In the previous steps we have obtained all the information required for this purpose (using the <em>ifconfig</em> and <em>route</em> commands). This information may already be present in your <em>vmbr0</em> stanza as well, in which case you can use this instead.</p>
<p>We edit the <em>eth0</em> stanza to look as following:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">auto eth0 iface<br />
eth0 inet static<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;address 91.11.22.33<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;netmask 255.255.255.0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;broadcast 91.11.22.255<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;gateway 91.11.22.254</div></div>
</pre>
<p>Where the example IPs are replaced by the actual address, netmask, broadcast and gateway IPs found in the previous steps or obtained from the current <em>vmbr0</em> stanza.</p>
<blockquote><p>WARNING: It is important to understand that editing the <em>eth0</em> stanza can lead to an inability to connect to the server if done incorrectly. If you rely on remote access such as SSH, or if you are uncertain about the information that needs to be entered in the various fields, please contact your administrator or hosting provider for assistance. As always, use care and make backups of existing files.</p></blockquote>
<h3 id="change_vmbr0">Change the vmbr0 network interface</h3>
<p>The <em>vmbr0</em> stanza in the <em>/etc/network/interfaces</em> will be changed to look like:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">... (original configuration) ...<br />
<br />
auto vmbr0<br />
iface vmbr0 inet static<br />
&nbsp; &nbsp; &nbsp; &nbsp; address 10.254.254.254<br />
&nbsp; &nbsp; &nbsp; &nbsp; netmask 255.0.0.0<br />
&nbsp; &nbsp; &nbsp; &nbsp; broadcast 10.255.255.255<br />
&nbsp; &nbsp; &nbsp; &nbsp; bridge_ports none<br />
&nbsp; &nbsp; &nbsp; &nbsp; bridge_stp off<br />
&nbsp; &nbsp; &nbsp; &nbsp; bridge_fd 0</div></div>
</pre>
<p>The significant changes here are the IP addresses used for the <em>address</em>, <em>netmask</em> and <em>broadcast</em> as well as changing <em>bridge_ports</em> to &#8220;none&#8221;.  The IP address of 10.254.254.254 can be any in the 10.0.0.0/8 range and so may be changed if you wish. It will later be used as the gateway address for the virtual servers.</p>
<p>The changes can be applied without having to reboot the system using:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>networking restart</div></div>
</pre>
<h2><span>Shorewall</span></h2>
<p>Installing Shorewall is simply a matter of executing the following command:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> shorewall</div></div>
</pre>
<p>If you wish to use shorewall with IPv6 capabilities, a few additional steps will be required. At the moment of writing, Debian has not included the latest version of Shorewall6 into its main package source. You will therefore need to add the SID (unstable branch) to your available package sources:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;deb http://ftp.fr.debian.org/debian sid main&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span>sources.list<br />
<span style="color: #c20cb9; font-weight: bold;">aptitude</span> update</div></div>
</pre>
<p>Once this has been done, Shorewall with IPv6 support &#8211; aptly named shorewall6 &#8211; can be installed with:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> shorewall6</div></div>
</pre>
<p>It is important to note that Shorewall6 makes a strict distinction between IPv4 and IPv6 and each has to be configured individually. That is, the files located in <em>/etc/shorewall/</em> are for IPv4 only and <em>/etc/shorewall6/</em> contains files related to IPv6 only. <span style="text-decoration: underline;">The IPv4 version cannot control what will happen on IPv6 and vice versa!</span></p>
<p>Most rules and policies in for Shorewall are directly transferable between <em>/etc/shorewall/</em> and <em>/etc/shorewall6/</em>. Due to this, this article will only focus on IPv4 configuration with one exception:</p>
<p>You will want to edit the <em>/etc/shorewall/shorewall.conf</em> file, and change the following value from:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DISABLE_IPV6=Yes</div></div>
</pre>
<p>to:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DISABLE_IPV6=No</div></div>
</pre>
<p>If this is not done, any configuration done in <em>/etc/shorewall6/</em> would be ignored (and will also disable any existing IPv6 traffic).</p>
<h3>Enable IP Forwarding</h3>
<p>First, a minor modification to the Shorewall application configuration is made to enable IP forwarding. This will permit some functions that will be discussed later.</p>
<p>Edit <em>/etc/shorewall/shorewall.conf</em> and change the following value from:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">IP_FORWARDING=Off</div></div>
</pre>
<p>to:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">IP_FORWARDING=On</div></div>
</pre>
<h3>Zones</h3>
<p>The <em>/etc/shorewall/zones</em> file is created to establish the zones names and what type of zones they are:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#ZONE &nbsp; TYPE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OPTIONS &nbsp; &nbsp; &nbsp; &nbsp; IN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OUT<br />
# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OPTIONS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OPTIONS<br />
fw &nbsp; &nbsp; &nbsp;firewall<br />
net &nbsp; &nbsp; ipv4<br />
dmz &nbsp; &nbsp; ipv4</div></div>
</pre>
<p>The <em>fw</em> zone is a self-reference to the server on which Shorewall is running. Note that this will not include the Proxmox virtual servers; you have to consider this as an entirely separate server in this sense.</p>
<h3>Interfaces</h3>
<p>The network interfaces on the server need to be defined and assigned to a specific zone. The <em>net</em> zone will be assigned to the <em>eth0</em> network interface and will designate all traffic coming from or going to the internet. The <em>dmz</em> zone will be the internal zone for the virtual network, which will contain the virtual servers that either use <em>venet</em> or <em>veth</em> network interfaces.</p>
<p>Create the <em>/etc/shorewall/interfaces</em> file and add the following:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#ZONE &nbsp; INTERFACE &nbsp; &nbsp; &nbsp; BROADCAST &nbsp; &nbsp; &nbsp; OPTIONS<br />
net &nbsp; &nbsp; eth0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;detect &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;blacklist,nosmurfs<br />
dmz &nbsp; &nbsp; venet0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;detect &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;routeback<br />
dmz &nbsp; &nbsp; vmbr0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; detect &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;routeback,bridge</div></div>
</pre>
<h3>Policy</h3>
<p>A base policy needs to defined for each one of the zones. It specifies the default actions on in- and outgoing traffic, and in this article the following policies will be defined:</p>
<p>Traffic from the firewall to:</p>
<ul style="padding-left: 30px;">
<li>the internet is permitted</li>
<li>DMZs is permitted</li>
<li>other processes on the firewall is permitted</li>
</ul>
<p>Traffic from the DMZ (virtual servers) to:</p>
<ul style="padding-left: 30px;">
<li>another virtual server is permitted</li>
<li>the internet is permitted</li>
<li>the firewall is denied and 1 information message per second (with a burst of 2) will be record when access is attempted.</li>
</ul>
<p>Traffic from the internet to:</p>
<ul style="padding-left: 30px;">
<li>the firewall is denied</li>
<li>DMZs is denied, generating 8 messages per second (with a burst of 30 messages) whenever access is attempted.</li>
</ul>
<p>Any traffic not defined in any of the zones (either by accident or purposely) will be rejected.</p>
<p>To do this, we will create the <em>/etc/shorewall/policy</em> file:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#SOURCE DEST &nbsp; &nbsp;POLICY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LOG &nbsp; &nbsp; LIMIT: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CONNLIMIT:<br />
# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LEVEL &nbsp; BURST &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MASK<br />
<br />
# From Firewall Policy<br />
fw &nbsp; &nbsp; &nbsp;fw &nbsp; &nbsp; &nbsp;ACCEPT<br />
fw &nbsp; &nbsp; &nbsp;net &nbsp; &nbsp; ACCEPT<br />
fw &nbsp; &nbsp; &nbsp;dmz &nbsp; &nbsp; ACCEPT<br />
<br />
# From DMZ Policy<br />
<br />
dmz &nbsp; &nbsp; dmz &nbsp; &nbsp; ACCEPT<br />
dmz &nbsp; &nbsp; net &nbsp; &nbsp; ACCEPT<br />
dmz &nbsp; &nbsp; fw &nbsp; &nbsp; &nbsp;DROP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;info<br />
<br />
# From Net Policy<br />
net &nbsp; &nbsp; fw &nbsp; &nbsp; &nbsp;DROP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;info<br />
net &nbsp; &nbsp; dmz &nbsp; &nbsp; DROP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;info <br />
<br />
# THE FOLLOWING POLICY MUST BE LAST<br />
#<br />
all &nbsp; &nbsp; all &nbsp; &nbsp; REJECT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;info</div></div>
</pre>
<p><strong>Update:</strong> For those who have followed this guide before and are experiencing some performance issues, please remove the limit burst options after &#8220;info&#8221;, ie &#8220;1/sec:2&#8243;. The reason is that this takes priority over rules; this was a painful discovery on my end!</p>
<h3>Basic Rules</h3>
<p>The policy defined earlier will deny any traffic coming from the internet to the firewall, which will include the SSH service and the Proxmox web-based manager. Since this is undesirable, a few rules need to be created that override this base policy.</p>
<p>Create the<em> /etc/shorewall/rules</em> file:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#ACTION &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SOURCE &nbsp; &nbsp; DEST &nbsp; &nbsp; &nbsp; PROTO &nbsp; DEST &nbsp; &nbsp; &nbsp; &nbsp;SOURCE &nbsp; &nbsp; ORIGINAL &nbsp; &nbsp;RATE<br />
<br />
# Permit access to SSH<br />
SSH/ACCEPT &nbsp; &nbsp; &nbsp; net &nbsp; &nbsp; &nbsp; &nbsp;fw &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;6/min:5<br />
<br />
# Permit access to Proxmox Manager and Console<br />
ACCEPT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; net &nbsp; &nbsp; &nbsp; &nbsp;fw &nbsp; &nbsp; &nbsp; &nbsp; tcp &nbsp; &nbsp; 443,5900:5999<br />
<br />
# PING Rules<br />
Ping/ACCEPT &nbsp; &nbsp; &nbsp;all &nbsp; &nbsp; &nbsp; &nbsp;all<br />
<br />
# LAST LINE -- DO NOT REMOVE</div></div>
</pre>
<p>As you may notice, there is also an additional rule for <em>ping</em>. For testing purposes, it would be wise to permit a ping from and to any of your zone, including the internet.</p>
<p>The <em>SSH/ACCEPT</em> rule is in fact a macro that comes with Shorewall. You could also define the same rule as following:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ACCEPT &nbsp; &nbsp; &nbsp; net &nbsp; &nbsp; &nbsp; &nbsp;fw &nbsp; &nbsp; &nbsp; &nbsp; tcp &nbsp; &nbsp; &nbsp; 22 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;6/min:5</div></div>
</pre>
<p>Also, at the very end of the SSH rule you notice <em>&#8220;6/min:5&#8243;</em>. This specifies the connection rate and in this case it reduces the connection rate to 6 per minute (1 per 10 seconds) with a maximum initial burst of 5. It is added here to slow down brute force SSH attacks.</p>
<h3>Testing Configuration</h3>
<p>After creating the files, your <em>/etc/shorewall/</em> directory might look similar to:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">drwxr-xr-x &nbsp;2 root root 4096 2009-07-01 06:36 .<br />
drwxr-xr-x 82 root root 4096 2009-07-06 10:03 ..<br />
-rw-r--r-- &nbsp;1 root root &nbsp;522 2009-06-26 20:05 interfaces<br />
-rw-r--r-- &nbsp;1 root root &nbsp;453 2007-11-15 23:24 Makefile<br />
-rw-r--r-- &nbsp;1 root root &nbsp;781 2009-06-26 21:16 policy<br />
-rw-r--r-- &nbsp;1 root root 2355 2009-07-02 22:42 rules<br />
-rw-r--r-- &nbsp;1 root root 4134 2009-06-20 21:58 shorewall.conf<br />
-rw-r--r-- &nbsp;1 root root &nbsp;438 2009-06-26 20:04 zones</div></div>
</pre>
<p>Before using the configuration you will want to test it first, particularly to make sure you are not blocking SSH access. Issue the following command:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">shorewall try <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>shorewall <span style="color: #000000;">60</span></div></div>
</pre>
<p>The parameter <em>60</em> refers to 60 seconds. Shorewall will use the configuration located in <em>/etc/shorewall/</em> for 60 seconds and then reverts to the previous settings (or no firewall).</p>
<p>After issuing the command, establish a new connection to your server using SSH and check whether your Proxmox web-based manager is accessible. If you are receiving error messages from Shorewall or you are unable to access SSH during the 60-second test period, please verify the configuration and try again.</p>
<h3>Starting Shorewall</h3>
<p>By default Shorewall is not enabled during boot time as a safety precaution for first-time configurations. To enable it, edit <em>/etc/default/shorewall</em> file and change:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">startup=0</div></div>
</pre>
<p>to:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">startup=1</div></div>
</pre>
<p>You can start Shorewall manually with:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">shorewall start</div></div>
</pre>
<p>And after making any changes to the Shorewall configuration, issue the command:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">shorewall restart</div></div>
</pre>
<p>Note: It is best not to use <em>/etc/init.d/shorewall restart</em>. Doing so will temporarily disable the firewall, which permits access to normally blocked ports. Although this period is brief, it may still be enough time for someone to establish a connection to the server &#8211; Shorewall does not block existing connections by default.</p>
<h2><span>Proxmox</span></h2>
<p>Once Shorewall has been configured, there will be three distinct zones on the Proxmox server:</p>
<ul>
<li>the Firewall / Proxmox host at <em>fw</em></li>
<li>the virtual network zone for virtual servers at <em>dmz</em></li>
<li>the internet at <em>net</em></li>
</ul>
<h3>IP Assignment</h3>
<p>To further separate the internet and virtual servers as distinct areas, each virtual server will be assigned an IP address in the 10.0.0.0/8 range (10.0.0.1 &#8211; 10.255.255.254).</p>
<p>The exception is that one can no longer use 10.254.254.254 as this has been assigned to the <em>vmbr0</em> network interface earlier in this guide.</p>
<h3>Outgoing internet traffic</h3>
<p>Due to this separation and the use of A-class (10.0.0.0/8) IP addresses, outgoing traffic from a virtual server to the internet needs to be translated (so that Shorewall and other Internet routers know where to send responses to). This will be defined in the <em>/etc/shorewall/masq</em> file.</p>
<p>In its simplest form, <em>/etc/shorewall/masq</em> can be set to the follwing:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#INTERFACE &nbsp; &nbsp; &nbsp;SOURCE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ADDRESS &nbsp; &nbsp; &nbsp; &nbsp; PROTO &nbsp; PORT(S) IPSEC &nbsp; MARK<br />
eth0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10.0.0.0/8<br />
<br />
# LAST LINE -- DO NOT REMOVE</div></div>
</pre>
<p>This means that all traffic originating from 10.0.0.0/8 and going to the internet will pass through the <em>eth0</em> network interface using the IP address assigned to <em>eth0</em>.</p>
<p>If you wish to make all traffic appear from a particular IP addresses, it can be specified as the third parameter. For example:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">eth0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10.0.0.0/8 &nbsp; &nbsp;91.121.0.1</div></div>
</pre>
<p>Or perhaps there&#8217;s a specific internal IP address that must appear externally as another IP address, you can do this as folowing:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">+eth0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 10.0.1.101 &nbsp; &nbsp;91.121.0.2<br />
eth0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10.0.0.0/8 &nbsp; &nbsp;91.121.0.1</div></div>
</pre>
<p>Notice the plus (&#8216;+&#8217;) sign in front of <em>eth0</em>. All traffic from 10.0.0.0/8 will appear to be coming from IP 91.121.0.1, except traffic coming from 10.0.1.101 will appear as coming from 91.121.0.2.</p>
<h3>Incoming internet traffic</h3>
<p>The separation between the internet and virtual servers not only applies to outgoing traffic, but also incoming traffic. There are two methods of directing incoming traffic,which is Proxy ARP or DNAT. This article will focus on DNAT; for more information on Proxy ARP and Shorewall, visit <a title="Proxy ARP and Shorewall" href="http://www.shorewall.net/manpages/shorewall-proxyarp.html" target="_blank">http://www.shorewall.net/manpages/shorewall-proxyarp.html</a>.</p>
<p>For example, to forward HTTP traffic on any external IP address to a virtual server with the assigned IP of 10.0.1.101, edit the <em>/etc/shorewall/rules</em> file as following:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">...(existing rules)...<br />
DNAT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;net &nbsp; &nbsp; dmz:10.0.1.101 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tcp &nbsp; &nbsp; 80</div></div>
</pre>
<p>The added benefit of DNAT is that a single IP address can be used for multiple virtual servers, provided that the traffic is on a different port. For example, HTTP traffic on external IP address 91.121.0.1 may be sent to a virtual server with the assigned IP of 10.0.1.101, whereas FTP traffic may be sent to a virtual server with assigned IP of 10.0.1.102 instead:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">...(existing rules)...<br />
DNAT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;net &nbsp; &nbsp; dmz:10.0.1.101 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tcp &nbsp; &nbsp; 80 &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp;91.121.0.1<br />
DNAT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;net &nbsp; &nbsp; dmz:10.0.1.102 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tcp &nbsp; &nbsp; 21,23 &nbsp; &nbsp;- &nbsp; &nbsp;91.121.0.1</div></div>
</pre>
<p>It is even possible to route traffic to a different internal port. For example, to forward HTTP traffic on external IP address 91.121.0.1 to a virtual server with the assigned IP of 10.0.1.103 and listening on 8180:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">...(existing rules)...<br />
DNAT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;net &nbsp; &nbsp; dmz:10.0.1.103:8180 &nbsp; &nbsp; tcp &nbsp; &nbsp; 80 &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp;91.121.0.1</div></div>
</pre>
<h3>Bridged Networking</h3>
<p>The <em>venet</em> network interface is certainly the simplest method to use in Proxmox. However, <em>venet</em> is not available in KVM (fully virtualized servers) and there may be another reason why you might want to use the <em>veth</em> network interfaces with regular containers (such as the use of DHCP).</p>
<p>For this reason the <em>vmbr0</em> network interface on the host was reconfigured to use the IP address of 10.254.254.254. It will act as the gateway entry for those virtual servers using <em>veth</em> network interfaces.</p>
<p>Although additional configuration needs to be done within a virtual server, you can use the same Shorewall rules for in- and outgoing traffic as described earlier (ie., DNAT or outgoing traffic).</p>
<h3>Linux (Debian)</h3>
<p>Inside a Debian Linux virtual server, you will specify <em>/etc/network/interfaces</em> as following:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">auto eth0<br />
iface eth0 inet static<br />
&nbsp; address 10.0.1.101<br />
&nbsp; netmask 255.0.0.0<br />
&nbsp; gateway 10.254.254.254</div></div>
</pre>
<p>where 10.0.1.101 is the IP address to be used by this particular virtual server.</p>
<p>If you are using both <em>venet</em> and veth network interfaces at the same time, as may be the case with certain IPv6 configurations, the file <em>/etc/network/interfaces<span style="text-decoration: underline;">.tail</span></em> should be used instead.</p>
<h3>Microsoft Windows</h3>
<p>For networking within Windows, proceed to your <em>Networking</em> control panel (or the <em>Network and Sharing Center</em>). Select the appropriate <em>Local Area Connection</em> and right-click to reveal the <em>Properties</em> menu option. UAC (User Account Control) may request your permission to proceed.</p>
<p>In the list of <em>This connection uses the following items</em>, select <em>Internet Protocol (TCP/IP)</em> (or <em>Internet Protocol Version 4 (TCP/IPv4)</em>). Click the <em>Properties</em> button.</p>
<p>At the <em>General</em> tab, change the following selections:</p>
<p>Use the following IP address:</p>
<ul>
<li>IP address: 10.0.1.101</li>
<li>Subnet mask: 255.0.0.0</li>
<li>Default gateway: 10.254.254.254</li>
</ul>
<p>Use the following DNS server addresses:</p>
<ul>
<li>Preferred DNS server: xxx.xxx.xxx.xxx</li>
<li>Alternate DNS server: yyy.yyy.yyy.yyy</li>
</ul>
<p>Where <em>xxx&#8230; </em>and <em>yyy&#8230;</em> are your preferred DNS servers.</p>
<h3>Non-private IP Assignment</h3>
<p>The setup as described above has separated your virtual servers from the internet by use of a zone (<em>dmz</em>) and A-class IP range (10.0.0.0/8). However, it is still possible to assign a non-private IP directly to one of your virtual servers if the <em>venet</em> network interface is used.</p>
<p>Internet traffic (from the <em>net</em> to the <em>dmz</em> zone) will still be blocked per the policy established in the above setup, and you will need to add additional rules to your Shorewall configuration. The major difference is that you must use <em>ACCEPT</em> instead of <em>DNAT</em>.</p>
<p>For example, let&#8217;s assume the IP address 91.121.0.1 was directly assigned to a virtual server. To permit internet Web traffic (port 80) to this container, add the following rule to your <em>/etc/shorewall/rules</em> file:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ACCEPT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;net &nbsp; &nbsp; dmz:91.121.0.1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tcp &nbsp; &nbsp; 80</div></div>
</pre>
<p>Please note that for <em>veth</em> network interfaces (bridged) Proxy ARP is required.</p>
<h2><span>Extra Hardening</span></h2>
<p>Following are considered advanced topics to further enhance the firewall and Proxmox. They may not be required in all situations.</p>
<h3>Restricting IP Addresses per MAC</h3>
<p>When the <em>veth</em> bridged networking is used in Proxmox, the virtual server will have a fully emulated network interface with its own MAC address. The downside is that Proxmox cannot assign the IP address directly and so you will have to configure this within the virtual server.</p>
<p>This should not be an issue if you have full control over the virtual server. However, if the virtual server belongs to a customer or in a worst case scenario is compromised, you no longer have full control over it and it will be possible to change or assign additional IP addresses to the virtual server.</p>
<p>Although earlier in this article containers have already been separated from the internet, it would still be possible to use a private IP address or network interface of an already existing other container. It may therefore be possible to spoof another virtual server.</p>
<p>To implement additional safeguards against this, Shorewall needs a few extra rules described here.</p>
<h3>Enable the maclist</h3>
<p>First the <em>maclist</em> option needs to be enabled for the interface we will monitor MAC / IP relations on. Your <em>/etc/shorewall/interfaces</em> may currently look like this:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#ZONE &nbsp; INTERFACE &nbsp; &nbsp; &nbsp; BROADCAST &nbsp; &nbsp; &nbsp; OPTIONS<br />
net &nbsp; &nbsp; eth0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;detect &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;blacklist,nosmurfs<br />
dmz &nbsp; &nbsp; venet0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;detect &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;routeback<br />
dmz &nbsp; &nbsp; vmbr0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; detect &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;routeback,bridge<br />
<br />
# LAST LINE -- DO NOT REMOVE</div></div>
</pre>
<p>We will add the <em>maclist</em> option to <em>vmbr0</em> in the <em>dmz</em> zone, ending up with:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">...<br />
dmz &nbsp; &nbsp; vmbr0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; detect &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;routeback,bridge,maclist<br />
<br />
# LAST LINE -- DO NOT REMOVE</div></div>
</pre>
<h3>Defining MAC / IP relation</h3>
<p>Now we need to obtain the MAC address of the <em>veth</em> interface used in the virtual server and there are several methods for this. We can obtain the MAC address from within the container by issuing the command:</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ifconfig</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> eth</div></div>
</pre>
<p>which produces an output similar to:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">eth0 &nbsp; &nbsp; &nbsp;Link encap:Ethernet &nbsp;HWaddr 00:18:51:f9:43:1e</div></div>
</pre>
<p>Alternatively, we can issue the following command from the host node (Proxmox server):</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vz<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/&lt;</span>VEID<span style="color: #000000; font-weight: bold;">&gt;</span>.conf <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-lne</span> <span style="color: #ff0000;">'print for /mac=(.*),host_ifn/g'</span></div></div>
</pre>
<p>Or in case it is a fully virtualized server (KVM):</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>qemu-server<span style="color: #000000; font-weight: bold;">/&lt;</span>VEID<span style="color: #000000; font-weight: bold;">&gt;</span>.conf <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-lne</span> <span style="color: #ff0000;">'print for /virtio=(.*)$/g'</span></div></div>
</pre>
<p>where <em>&lt;VEID&gt;</em> is the number of the virtual server (container) for which you wish to obtain the MAC address. This will produce an output similar to:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">00:18:51:F9:43:1E</div></div>
</pre>
<p>Once we have obtained the MAC address, we create (or edit) the <em>/etc/shorewall/maclist</em> file as following:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># DISPOSITION &nbsp; INTERFACE &nbsp; &nbsp; &nbsp; MAC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IP<br />
ACCEPT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vmbr0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 00:18:51:f9:43:1e &nbsp; &nbsp; &nbsp; 10.0.1.101<br />
# LAST LINE -- DO NOT REMOVE</div></div>
</pre>
<p>In this example, the MAC address has been provided in our earlier examples and the IP address 10.0.1.101 is the only permitted IP address that can be used by this virtual server.</p>
<p>Apply the changes by issuing the command</p>
<pre>
<div class="codecolorer-container bash blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">shorewall restart</div></div>
</pre>
<p>At this point, if the virtual server changed the IP address (or added another IP address) other than 10.0.1.101, that traffic will be rejected as per the default behaviour of a Shorewall installation on Proxmox/Debian. If this behaviour needs to be changed, it can be set in the <em>/etc/shorewall/shorewall.conf</em> file with this variable:</p>
<pre>
<div class="codecolorer-container text blackboard no_translate none" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">MACLIST_DISPOSITION=REJECT</div></div>
</pre>
<h3>Additonal Notes</h3>
<p>This guide is only intended to provide basic protection for your virtual servers and the Proxmox host node. No guarantees or warranties are implied, and you should always remain vigilant against potential network intrusions (in other words: do not rely on a firewall alone).</p>
<p>You may also wish to configure Shorewall according to your particular needs. For example, in this guide virtual servers are permitted to connect to each other within the <em>dmz</em> zone and could pose a risk.  You may wish to shield the virtual servers from each other in case one of them has been compromised (hint: edit the policy).</p>
<p>The Shorewall website includes numerous examples in its <a title="Shorewall Documentation" href="http://www.shorewall.net/Documentation_Index.html" target="_blank">documentation</a> that may help you further.</p>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/&amp;title=Guide%3A+Firewall+and+router+with+Proxmox" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/&amp;title=Guide%3A+Firewall+and+router+with+Proxmox" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/&amp;title=Guide%3A+Firewall+and+router+with+Proxmox&amp;desc=By%20default%20Proxmox%20does%20not%20come%20with%20a%20firewall%2C%20which%20may%20leave%20it%20and%20your%20virtual%20servers%20exposed%20to%20the%20elements%20of%20the%20Internet.%0D%0A%0D%0AAn%20additional%20issue%20arises%20when%20a%20hosting%20provider%20blocks%20servers%20if%20unauthorized%20MAC%20addresses%20are%20detected.%20As%20Proxmox%27s%20bridged%20network%20creates%20and%20exposes%20MAC" rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/&amp;imageurl=" rel="nofollow" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/&amp;bm_description=Guide%3A+Firewall+and+router+with+Proxmox&amp;plugin=sexybookmarks" rel="nofollow" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/&amp;title=Guide%3A+Firewall+and+router+with+Proxmox" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/&amp;title=Guide%3A+Firewall+and+router+with+Proxmox" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/&amp;title=Guide%3A+Firewall+and+router+with+Proxmox" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Guide%3A+Firewall+and+router+with+Proxmox+-+http://bit.ly/j8KVe&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.myatus.co.uk/2010/03/20/guide-firewall-and-router-with-proxmox-extending-its-us/' rel='bookmark' title='Permanent Link: Guide: Firewall and router with Proxmox &#8211; Extending its use'>Guide: Firewall and router with Proxmox &#8211; Extending its use</a></li>
<li><a href='http://www.myatus.co.uk/2009/10/20/quick-debianubuntu-networking-tips/' rel='bookmark' title='Permanent Link: Quick Debian/Ubuntu networking tips'>Quick Debian/Ubuntu networking tips</a></li>
<li><a href='http://www.myatus.co.uk/2010/07/17/blocking-w00tw00t-scans/' rel='bookmark' title='Permanent Link: Blocking w00tw00t scans'>Blocking w00tw00t scans</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.myatus.co.uk/2009/08/31/guide-firewall-and-router-with-proxmox/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
