<?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>MrBrown blob &#187; lighttpd</title>
	<atom:link href="http://charles.lescampeurs.org/tag/lighttpd/feed" rel="self" type="application/rss+xml" />
	<link>http://charles.lescampeurs.org</link>
	<description>random bits.</description>
	<lastBuildDate>Sat, 10 Apr 2010 09:02:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Maintenance mode (HTTP 503) with lighttpd and PHP</title>
		<link>http://charles.lescampeurs.org/2008/07/22/maintenance-mode-http-503-with-lighttpd-and-php</link>
		<comments>http://charles.lescampeurs.org/2008/07/22/maintenance-mode-http-503-with-lighttpd-and-php#comments</comments>
		<pubDate>Tue, 22 Jul 2008 00:28:08 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[http]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=28</guid>
		<description><![CDATA[When you put your website in maintenance mode, it&#8217;s a good idea to return a HTTP 503 error code to the client. This code indicates that &#8220;the server is currently unable to handle the request due to a temporary overloading or maintenance of the server&#8221;. The 503 code is used to avoid crawlers or caching [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcharles.lescampeurs.org%2F2008%2F07%2F22%2Fmaintenance-mode-http-503-with-lighttpd-and-php"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcharles.lescampeurs.org%2F2008%2F07%2F22%2Fmaintenance-mode-http-503-with-lighttpd-and-php&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>When you put your website in maintenance mode, it&#8217;s a good idea to return a HTTP 503 error code to the client.</p>
<p>This code indicates that <em>&#8220;the server is currently unable to handle the request due to a    temporary overloading or maintenance of the server&#8221;</em>.</p>
<p>The 503 code is used to avoid crawlers or caching proxy use the maintenance page as the new valid content for the request. You certainly don&#8217;t want Google save this content in his search index as the content of your website <img src='http://charles.lescampeurs.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>To achieve this we will use a rewrite rule in lighttpd to redirect all requests to a single PHP script which will return a 503 error code and print an informative message.</p>
<h2>Lighttpd configuration</h2>
<pre>url.rewrite = ( "" =&gt; "/maintenance.php" )</pre>
<p>This configuration will redirect any request to maintenance.php script.</p>
<p>If you need to serve an image in your maintenance page, you have to add another rule to the rewrite process like that :</p>
<pre>url.rewrite = ( "upgrading.png" =&gt; "$0",
                "" =&gt; "/maintenance.php" )</pre>
<h3>Let some users see the website</h3>
<p>It might be usefull to let admins or developers access the website during the maintenance.<br />
For that, you can disable the maintenance rewrite rule for certain IP addresses :</p>
<pre> $HTTP["remoteip"] != “192.168.1.42″ {
               url.rewrite = ( "upgrading.png" =&gt; "$0",
                      "" =&gt; "/maintenance.php" )
}</pre>
<h2>PHP code example</h2>
<pre>&lt;?php
header("HTTP/1.1 503 Service Unavailable");
?&gt;
We're currently upgrading our servers...</pre>
<h2>Links</h2>
<ul>
<li><a title="HTTP/1.1 error codes" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html" target="_blank">RFC 2616 HTTP/1.1</a></li>
<li><a title="HTTP status codes" href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes">HTTP status codes on Wikipedia</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2008/07/22/maintenance-mode-http-503-with-lighttpd-and-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Permanent redirect (301) with lighttpd</title>
		<link>http://charles.lescampeurs.org/2008/06/30/permanent-redirect-301-with-lighttpd</link>
		<comments>http://charles.lescampeurs.org/2008/06/30/permanent-redirect-301-with-lighttpd#comments</comments>
		<pubDate>Mon, 30 Jun 2008 21:47:37 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[http]]></category>
		<category><![CDATA[lighttpd]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=25</guid>
		<description><![CDATA[If you want to redirect visitors that access your website without the &#8216;www&#8217;, you can use mod_redirect with the following syntax: $HTTP[”host”] =~ “^lescampeurs\.org” { url.redirect = ( ”^/(.*)$” =&#62; “http://www.lescampeurs.org/$1″ ) } Links: Lighttpd mod_redirect HTTP 3xx status codes]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcharles.lescampeurs.org%2F2008%2F06%2F30%2Fpermanent-redirect-301-with-lighttpd"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcharles.lescampeurs.org%2F2008%2F06%2F30%2Fpermanent-redirect-301-with-lighttpd&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>If you want to redirect visitors that access your website without the &#8216;www&#8217;, you can use <em>mod_redirect</em> with the following syntax:</p>
<pre>$HTTP[”host”] =~ “^lescampeurs\.org” {
    url.redirect = (
        ”^/(.*)$” =&gt; “http://www.lescampeurs.org/$1″
    )
}
</pre>
<p>Links:</p>
<ul>
<li><a title="mod_redirect with lighttpd" href="http://trac.lighttpd.net/trac/wiki/Docs:ModRedirect" target="_blank">Lighttpd mod_redirect</a></li>
<li><a title="HTTP 3xx status codes" href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection" target="_blank">HTTP 3xx status codes</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2008/06/30/permanent-redirect-301-with-lighttpd/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Deny access to .svn directories with Apache2 / lighttpd</title>
		<link>http://charles.lescampeurs.org/2008/05/28/deny-access-to-svn-directories-with-apache2-lighttpd</link>
		<comments>http://charles.lescampeurs.org/2008/05/28/deny-access-to-svn-directories-with-apache2-lighttpd#comments</comments>
		<pubDate>Wed, 28 May 2008 05:17:31 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[http]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=19</guid>
		<description><![CDATA[If you&#8217;re using SVN to control your web application, your certainly need to deny access to .svn sub-directories. With Apache2 &#60;DirectoryMatch "^/.*/\.svn/"&#62; Order allow,deny Deny from all &#60;/DirectoryMatch&#62; With lighttpd $HTTP["url"] =~ "/\.svn/" { url.access-deny = ( "" ) }]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcharles.lescampeurs.org%2F2008%2F05%2F28%2Fdeny-access-to-svn-directories-with-apache2-lighttpd"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcharles.lescampeurs.org%2F2008%2F05%2F28%2Fdeny-access-to-svn-directories-with-apache2-lighttpd&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>If you&#8217;re using SVN to control your web application, your certainly need to deny access to <em>.svn</em> sub-directories.</p>
<h2>With Apache2</h2>
<pre>    &lt;DirectoryMatch "^/.*/\.svn/"&gt;
            Order allow,deny
            Deny from all
    &lt;/DirectoryMatch&gt;</pre>
<h2>With lighttpd</h2>
<pre>    $HTTP["url"] =~ "/\.svn/" {
        url.access-deny = ( "" )
    }</pre>
]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2008/05/28/deny-access-to-svn-directories-with-apache2-lighttpd/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Use mod_redirect with lighttpd</title>
		<link>http://charles.lescampeurs.org/2008/05/06/use-mod_redirect-with-lighttpd</link>
		<comments>http://charles.lescampeurs.org/2008/05/06/use-mod_redirect-with-lighttpd#comments</comments>
		<pubDate>Tue, 06 May 2008 10:56:08 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[http]]></category>
		<category><![CDATA[lighttpd]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=5</guid>
		<description><![CDATA[Enable mod_redirect server.modules += ( "mod_redirect" ) Force your domain with www. $HTTP["host"] =~ "^domain\.com$" { url.redirect = ( "^/(.*)" =&#62; "http://www.domain.com/$1" ) } Force your domain without www. $HTTP["host"] =~ "^www\.domain\.com$" { url.redirect = ( "^/(.*)" =&#62; "http://domain.com/$1" ) } Redirect HTTP requests to HTTPS $SERVER["socket"] == ":80" { $HTTP["host"] =~ "(.*)" { url.redirect [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcharles.lescampeurs.org%2F2008%2F05%2F06%2Fuse-mod_redirect-with-lighttpd"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcharles.lescampeurs.org%2F2008%2F05%2F06%2Fuse-mod_redirect-with-lighttpd&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<h2>Enable mod_redirect</h2>
<pre>server.modules += ( "mod_redirect" )</pre>
<h2>Force your domain with www.</h2>
<pre>$HTTP["host"] =~ "^domain\.com$" {
    url.redirect = ( "^/(.*)" =&gt; "http://www.domain.com/$1" )
}</pre>
<h2>Force your domain without www.</h2>
<pre>$HTTP["host"] =~ "^www\.domain\.com$" {
    url.redirect = ( "^/(.*)" =&gt; "http://domain.com/$1" )
}</pre>
<h2>Redirect HTTP requests to HTTPS</h2>
<pre>$SERVER["socket"] == ":80" {
    $HTTP["host"] =~ "(.*)" {
        url.redirect = ( "^/(.*)" =&gt; "https://%1/$1" )
    }
}</pre>
<h2>Redirect an old domain to your new domain</h2>
<pre>$HTTP["host"] =~ "^www1\.domain\.com" {
    url.redirect = ( "^/(.*)" =&gt; "http://www.domain.com/$1" )
}</pre>
<h2>Redirect a url that can be matched by a mod_rewrite rule</h2>
<p>Lets say that you want to redirect http://www.domain.com/party to http://blog.domain.com/party while you have a mod_rewrite rule on www.domain.com that redirect all URLs to a controller (&#8220;^(.*)$&#8221; =&gt; &#8220;/index.php$1&#8243;).</p>
<p>Your redirect will not work because <em>mod_rewrite</em> always execute before redirect rules. To bypass this, you need to use the $0 as the rule target to pass URLs through unmangled.</p>
<p>e.g.</p>
<pre>url.redirect = ( "^/party(.*)" =&gt; "http://blog.domain.com/party$1" )
url.rewrite-once = ( "^/party" =&gt; "$0" )</pre>
<p><em>tested with lighttpd 1.4.x</em></p>
]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2008/05/06/use-mod_redirect-with-lighttpd/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
