Password protect directories with htaccess

From BubbaWiki
Jump to: navigation, search

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