<?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>Reliably Broken &#187; nginx</title>
	<atom:link href="http://reliablybroken.com/b/tag/nginx/feed/" rel="self" type="application/rss+xml" />
	<link>http://reliablybroken.com/b</link>
	<description>It&#039;s a blog: let&#039;s do funch!</description>
	<lastBuildDate>Thu, 01 Dec 2011 21:27:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Building Nginx 0.9.5 on Debian Lenny</title>
		<link>http://reliablybroken.com/b/2011/03/building-nginx-on-debian-lenny/</link>
		<comments>http://reliablybroken.com/b/2011/03/building-nginx-on-debian-lenny/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 21:00:33 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://reliablybroken.com/b/?p=609</guid>
		<description><![CDATA[Nginx is available in Debian Lenny, but the version in stable is the old 0.6.x series. Perusio maintains a useful repository with development versions built for Lenny, but it requires libraries newer than those in stable. UPDATED: fixed &#8216;build-essential&#8217; &#8211; thank you Carlos But it is easy enough to build a deb from the Perusio [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://nginx.org/">Nginx</a> is available in <a href="http://www.debian.org/releases/lenny/">Debian Lenny</a>, but the version in stable is the old 0.6.x series. <a href="http://debian.perusio.net/">Perusio maintains a useful repository</a> with development versions built for Lenny, but it requires libraries newer than those in stable.</p>

<p><em>UPDATED: fixed &#8216;build-essential&#8217; &#8211; thank you Carlos</em></p>

<p>But it is easy enough to build a <a href="http://www.debian.org/doc/FAQ/ch-pkg_basics">deb</a> from the Perusio package which uses the stable libraries. Here are my notes. N.B. Editing the apt sources and installing packages needs root privileges.</p>

<p>First, add the Perusio repository to <code>/etc/apt/sources.list</code>:</p>

<pre><code>cat &gt;&gt; /etc/apt/sources.list &lt;&lt;EOF
deb http://debian.perusio.net unstable/
deb-src http://debian.perusio.net unstable/
EOF
</code></pre>

<p>Update the apt-get index:</p>

<pre><code>apt-get update
</code></pre>

<p>Install packaging tools (if they aren&#8217;t installed already):</p>

<pre><code>apt-get install dpkg-dev
apt-get install fakeroot
apt-get install debhelper
apt-get install build-essential
</code></pre>

<p>Install headers for libaries required to build Nginx:</p>

<pre><code>apt-get install autotools-dev libgeoip-dev libssl-dev libpcre3-dev zlib1g-dev
</code></pre>

<p>Now get the package source and build a deb installation package. This part can be done as a non-root user.</p>

<pre><code>apt-get source nginx
cd nginx-0.9.5
dpkg-buildpackage -rfakeroot -uc -b
</code></pre>

<p>When I did this, the version in the repository was Nginx 0.9.5. The flag <code>-uc</code> says to not sign the changes file and <code>-b</code> says build a binary-only distribution. If you were cross-compiling, you can pass the <code>-a</code> flag to dpkg-buildpackage specifying the build architecture.</p>

<p>Assuming the build was successful, your new installation package will have been created in the parent directory (bloody hell Debian tools are unintuitive).</p>

<p>Here I built the deb on amd64. To install this I go:</p>

<pre><code>dpkg -i ../nginx_0.9.5-perusio.1.0_amd64.deb
</code></pre>

<p>The advantage of building Nginx from Perusio&#8217;s repository rather than directly from the source is we get the hard work of conforming to the Debian layout for free.</p>
]]></content:encoded>
			<wfw:commentRss>http://reliablybroken.com/b/2011/03/building-nginx-on-debian-lenny/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Caching a Django app with Nginx + FastCGI</title>
		<link>http://reliablybroken.com/b/2011/02/caching-django-nginx/</link>
		<comments>http://reliablybroken.com/b/2011/02/caching-django-nginx/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 19:58:32 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://reliablybroken.com/b/?p=605</guid>
		<description><![CDATA[I just spent a stupid amount of time trying to figure why Nginx was failing to cache my Django app responses. The Django app is running as a FastCGI backend and I have Nginx using the fastcgi_cache directive to cache responses. The answer is that Nginx since version 0.8.44 does not cache backend responses if [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent a stupid amount of time trying to figure why <a href="http://nginx.org/">Nginx</a> was failing to cache my <a href="http://www.djangoproject.com/">Django</a> app responses. The Django app is running as a FastCGI backend and I have Nginx using the <a href="http://wiki.nginx.org/HttpFcgiModule#fastcgi_cache"><code>fastcgi_cache</code> directive</a> to cache responses.</p>

<p>The answer is that <a href="http://nginx.org/en/CHANGES">Nginx since version 0.8.44 does not cache backend responses if they have a &#8220;Set-Cookie&#8221; header</a>. This makes perfect sense because you don&#8217;t want a response which sets a cookie to be cached for subsequent requests, but I was stupid because I had totally forgotten that my Django app was using a POST form for all responses for non-authenticated clients (due to how <a href="http://docs.djangoproject.com/en/dev/ref/contrib/csrf/">Django&#8217;s CSRF middleware</a> does its stuff).</p>

<p>The solution was to change the app so that it uses the GET method on the form in question, which in this case is fine from a security point-of-view.</p>

<p>The moral of this story is I should pay attention to my HTTP response headers and that I am badly short-sighted both figuratively and literally. With that fixed the site has gone from 15 requests per second to ~2000 requests per second!</p>
]]></content:encoded>
			<wfw:commentRss>http://reliablybroken.com/b/2011/02/caching-django-nginx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nginx and WordPress</title>
		<link>http://reliablybroken.com/b/2010/05/nginx-and-wordpress/</link>
		<comments>http://reliablybroken.com/b/2010/05/nginx-and-wordpress/#comments</comments>
		<pubDate>Sat, 01 May 2010 08:18:08 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://reliablybroken.com/b/?p=441</guid>
		<description><![CDATA[My Nginx and WordPress configuration on Debian Linux 5 (Lenny). This has Nginx as the Web server using the fastcgi module to talk to php-cgi processes that run WordPress with pretty URLs. The virtual private server I installed this on (from John Companies) has a 256 megabyte slice, so I figured a regular Apache + [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://nginx.org/">Nginx</a> and <a href="http://wordpress.org/">WordPress</a> configuration on <a href="http://wiki.debian.org/DebianLenny">Debian Linux 5 (Lenny)</a>. This has Nginx as the Web server using the fastcgi module to talk to php-cgi processes that run WordPress with pretty URLs.</p>

<p>The virtual private server I installed this on (from <a href="http://www.johncompanies.com/">John Companies</a>) has a 256 megabyte slice, so I figured a regular Apache + mod_php setup might be in trouble seeing as one of the sites I am running gets several thousand visits a day. Up to now I have always used Apache with mod_php to run WordPress, and anyway it is fun to learn how unfamiliar software works (<a href="http://www.ibm.com/software/lotus/products/notes/">Lotus Notes</a> excepted).</p>

<p>On a side note, <a href="http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/ref-guide/s1-boot-init-shutdown-sysv.html">SysV run-levels</a> and /etc/rcX.d directories are needlessly clever. <a href="http://sysv-rc-conf.sourceforge.net/">sysv-rc-conf</a> makes editing those easy.</p>

<pre><code>server {
    listen   80;
    server_name  example.com;

    root   /home/david/example.com;
    index  index.php index.html index.htm;
    error_page   500 502 503 504  /50x.html;

    location / {

    }

    location = /50x.html {
        root   /var/www/nginx-default;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    location ~ /\.ht {
        deny  all;
    }

    location /b/ {
        if (!-e $request_filename) {
            rewrite ^(.+)$ /b/index.php?q=$1 last;
        }
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

# Rewrite www.example.com to example.com
server {
    listen 80;
    server_name www.example.com;
    rewrite ^ http://example.com$request_uri?;
}
</code></pre>

<p>This configuration is for WordPress installed under http://example.com/b/ on my server.</p>
]]></content:encoded>
			<wfw:commentRss>http://reliablybroken.com/b/2010/05/nginx-and-wordpress/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

