    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>2skies.com :: basic http authentication with lighttpd</title>
        <link>http://2skies.com/docs/basic_http_authentication_with_lighttpd</link>
        <description>Hosting-Development-Support :: Experience the difference</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:support@2skies.com" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>

<!-- show a header for the current publication type -->
        <h2>library</h2>


<div class="xar-mod-head"><span class="xar-mod-title">web development and webmaster best practice + lighttpd</span></div>

<table border="0" cellpadding="1" cellspacing="0">
<tr>
    <td valign="top">
        Browse in :
   </td>
   <td valign="top">

                                    <a href="http://2skies.com/docs/">All</a>

                 &gt;                     <a href="http://2skies.com/docs/c43/">Documentation</a>

                 &gt;                     <a href="http://2skies.com/docs/c68/">knowledge base</a>
<br />

                                    <a href="http://2skies.com/docs/">All</a>

                 &gt;                     <a href="http://2skies.com/docs/c71/">Subject</a>

                 &gt;                     <a href="http://2skies.com/docs/c73/">Software</a>

                 &gt;                     <a href="http://2skies.com/docs/c74/">lighttpd</a>
<br />

                                    <a href="http://2skies.com/docs/c68-74/">Any of these categories</a>

                -                    <a href="http://2skies.com/docs/c68+74/">All of these categories</a>
<br />
</td>
</tr>
</table>






<div class="xar-alt-outline xar-fullwidth">
    <div class="xar-accent-outline xar-fullwidth">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
            <tr>
                <td align="left" valign="top" class="xar-normal">
                    <span class="xar-title"> basic http authentication with lighttpd</span>
                   <br />
                    <div align="right">
                        <span class="xar-sub">  </span>
                    </div>
                    <br />
                    <br />
                    <h3>lighttpd.conf</h3>
<p>Make sure you enable mod_access in your lighttpd.conf:</p>
<pre class="xml:nocontrols">server.modules += ( &quot;mod_access&quot; ) <br /></pre>
<h3>htpasswd</h3>
<pre class="xml:nocontrols">#htpasswd -c ~/lighttpd/foo-auth.xt username<br /></pre>
<p>Running this command will prompt for this user's new password to store in the txt file. Combining this with a special $HTTP[&quot;host&quot;] conditional ruleset in our lighttpd.conf will allow us to enable BASIC http authentication.</p>
<pre class="xml:nocontrols">$HTTP[&quot;host&quot;] =~ &quot;.*domainroot.*&quot; {<br />$HTTP[&quot;url&quot;] =~ &quot;^/somesubdir/&quot; {<br />auth.backend = &quot;htpasswd&quot;<br />auth.backend.htpasswd.userfile = &quot;/home/you/lighttpd/foo-auth.txt&quot;<br />auth.require = (&quot;/somesubdir&quot; =&gt; (<br />&quot;method&quot;  =&gt; &quot;basic&quot;,<br />&quot;realm&quot;   =&gt; &quot;anything&quot;,<br />&quot;require&quot; =&gt; &quot;valid-user&quot;<br />))<br />}<br />}<br /></pre>
<h3>Plain Text</h3>
<p>If you don't have access to htpasswd or don't care if the password is not encrypted, you can simply create a plain text file with the following:</p>
<pre class="xml:nocontrols">username:123<br /></pre>
<p>&quot;Username&quot; can be any user name you like and the &quot;123&quot; is the password.</p>
<p>The configuration is a little different for this form of authentication:</p>
<pre class="xml:nocontrols">$HTTP[&quot;url&quot;] =~ &quot;^/somesubdir&quot; {<br />auth.backend = &quot;plain&quot;<br />auth.backend.plain.userfile = &quot;/home/you/lighttpd/foo-auth.txt&quot;<br />auth.require = (&quot;/somesubdir&quot; =&gt; (<br />&quot;method&quot;  =&gt; &quot;basic&quot;,<br />&quot;realm&quot;   =&gt; &quot;whatever&quot;,<br />&quot;require&quot; =&gt; &quot;valid-user&quot;<br />))<br />} <br /></pre>
<p>Once this is in place, restart your lighttpd instance and users visiting the now protected url will be prompted with something like this:</p>
<p><img title="httpauth" src="assets/2skies/media/articleimages/httpauth.jpg" alt="httpauth" width="423" height="214" /></p>                    <br />
                    <span class="xar-quote">  </span>
</td>
           </tr>
       </table>
   </div>
</div>

<p>
Updated:  05 Apr 10 07:33</p>
<br />
   <table border="0" width="95%">
       <tr>
           <td align="left">
                    <a href="http://2skies.com/docs/an_easy_website_content_mirror">&lt;
 prev </a>
&nbsp;
           </td>
           <td align="right">
               &nbsp;
                    <a href="http://2skies.com/docs/Comparing_mysql_tables_with_mysqldump_and_diff">
 next &gt;</a>
</td>
       </tr>
   </table>
</channel>
</rss>
