<?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>Django Days &#187; Django hosting</title>
	<atom:link href="http://djangodays.com/category/django-hosting/feed/" rel="self" type="application/rss+xml" />
	<link>http://djangodays.com</link>
	<description>A growing collection of all things Django</description>
	<lastBuildDate>Tue, 20 Apr 2010 05:58:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>restrict access to Django site from all IP&#8217;s on Webfaction</title>
		<link>http://djangodays.com/2008/10/07/restrict-access-to-django-site-from-all-ips-on-webfaction/</link>
		<comments>http://djangodays.com/2008/10/07/restrict-access-to-django-site-from-all-ips-on-webfaction/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 13:28:36 +0000</pubDate>
		<dc:creator>Joost</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Django hosting]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Django tip]]></category>
		<category><![CDATA[ip filter]]></category>

		<guid isPermaLink="false">http://djangodays.com/?p=48</guid>
		<description><![CDATA[For this one project I wanted to deny all access to the site except for a certain IP address. I knew it could be done by using the mod_authz_host Apache Module (more info here), but I couldn&#8217;t get it to work on a Webfaction shared hosting account.
After exchanging some mails with the Webfaction support team [...]]]></description>
			<content:encoded><![CDATA[<p>For this one project I wanted to deny all access to the site except for a certain IP address. I knew it could be done by using the mod_authz_host Apache Module (more info <a href="http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html">here</a>), but I couldn&#8217;t get it to work on a <a href="http://www.webfaction.com/?affiliate=solidflux">Webfaction</a> shared hosting account.</p>
<p>After exchanging some mails with the Webfaction support team (which is absolutely awesome by the way: very helpfull and best response time i&#8217;ve seen!) I got it working! Thought I&#8217;d share the problem and the solution and might help save someone some frustration.</p>
<h3>The problem:</h3>
<p>I could not access the site when I tried the following in my httpd.conf:<br />
(xxx.xxx.xxx.xxx being the IP I wanted to grant access to)</p>
<p><code>&hellip;<br />
&lt;Location "/"&gt;<br />
    Order Deny,Allow<br />
    Deny from all<br />
    Allow from xxx.xxx.xxx.xxx<br />
&hellip;</code></p>
<p>I found the following line in my error_log:<br />
<code>[Fri Oct 03 06:10:47 2008] [error] [client 127.0.0.1] client denied by server configuration<br />
</code></p>
<p>This made something clear to me: Webfaction uses the apache2 webserver on a custom port, and the main webserver forwards the request through to the Django site. This works great but the problem here is that all the requests appear to be from 127.0.0.1 so I can&#8217;t exclude any ip&#8217;s in the httpd.conf file.</p>
<h3>The solution</h3>
<p>The solution is to use the Apache setenvif_module module to check for which ip the request was forwarded. Here&#8217;s part of an example httpd.conf file:<br />
<code>. . .<br />
LoadModule authz_host_module modules/mod_authz_host.so<br />
LoadModule setenvif_module modules/mod_setenvif.so<br />
&hellip;<br />
&lt;Location "/"&gt;</p>
<p>    # add a line like the following for each IP that you want to allow<br />
    SetEnvIf X-Forwarded-For "^xxx\.xxx\.xxx\.xxx$" allowed_ip</p>
<p>    Order Deny,Allow<br />
    Deny from all<br />
    Allow from env=allowed_ip<br />
&hellip;</code></p>
<p>If you got any questions about this, please use the comments below. If you&#8217;re looking for a good Django host for a reasonable price check out <a href="http://www.webfaction.com/?affiliate=solidflux">Webfaction </a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://djangodays.com/2008/10/07/restrict-access-to-django-site-from-all-ips-on-webfaction/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
