Difference between revisions of "Password protect directories with htaccess"

From BubbaWiki
Jump to navigation Jump to search
(Created page with 'It is possible to password protect directories that are available on the internet through Bubba.<br> 1. Create a public folder<br> <pre>mkdir /home/web/public </pre> 2. Create a...')
 
 
Line 1: Line 1:
It is possible to password protect directories that are available on the internet through Bubba.<br>
It is possible to password protect directories that are available on the internet through Bubba.<br>  


1. Create a public folder<br>
1. Create a public folder<br>  
<pre>mkdir /home/web/public
<pre>mkdir /home/web/public
</pre>
</pre>  
2. Create a password file with user "public"<br>
2. Create a password file with user "public"<br>  
<pre> htpasswd -c /home/web/public/.htpasswd public
<pre> htpasswd -c /home/web/public/.htpasswd public
</pre>
</pre>  
3. Create a htaccess file<br>
3. Create a htaccess file<br>  
<pre>touch /home/web/public/.htaccess
<pre>touch /home/web/public/.htaccess
</pre>
</pre>  
4. Edit the htaccess file and save it<br>
4. Edit the htaccess file and save it<br>  
 
<pre>nano /home/web/public/.htaccess
nano /home/web/.htaccess<br>
</pre> <pre>AuthGroupFile /dev/null
<pre>AuthGroupFile /dev/null
AuthName "Please login"
AuthName "Please login"
AuthType Basic
AuthType Basic
Line 21: Line 20:
&lt;/Limit&gt;
&lt;/Limit&gt;


</pre>
</pre>  
5. Modify Apache settings:<br>
5. Modify Apache settings:<br>  
<pre>nano /etc/apache2/sites-enabled/bubba
<pre>nano /etc/apache2/sites-enabled/bubba


</pre>
</pre>  
Change the parameter Allow Override on both port 80 and on port 443 virtual host settings:<br>
Change the parameter Allow Override on both port 80 and on port 443 virtual host settings:<br>  
<pre>&lt;Directory /home/web/&gt;
<pre>&lt;Directory /home/web/&gt;
Options Indexes FollowSymLinks MultiViews
Options Indexes FollowSymLinks MultiViews
Line 34: Line 33:
&lt;/Directory&gt;
&lt;/Directory&gt;


</pre>
</pre>  
6. Restart apache
6. Restart apache  
<pre>service apache2 restart
<pre>service apache2 restart
</pre>
</pre>  
7. Test by going to the directory: https://192.168.10.1/public
7. Test by going to the directory: https://192.168.10.1/public

Latest revision as of 15:28, 5 December 2010

It is possible to password protect directories that are available on the internet through Bubba.

1. Create a public folder

mkdir /home/web/public

2. Create a password file with user "public"

 htpasswd -c /home/web/public/.htpasswd public

3. Create a htaccess file

touch /home/web/public/.htaccess

4. Edit the htaccess file and save it

nano /home/web/public/.htaccess
AuthGroupFile /dev/null

AuthName "Please login" AuthType Basic

<Limit GET POST> require valid-user </Limit>

5. Modify Apache settings:

nano /etc/apache2/sites-enabled/bubba

Change the parameter Allow Override on both port 80 and on port 443 virtual host settings:

<Directory /home/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

6. Restart apache

service apache2 restart

7. Test by going to the directory: https://192.168.10.1/public