(SOLVED) Apache2 basic authentication not working
Hello.
I am trying to set up Apache2 basic authentication for the main web server directory /var/www but it's not working. I create password file with htpasswd, then put .htaccess file in /var/www with the following content: AuthType Basic AuthName "Restricted Files" AuthBasicProvider file AuthUserFile /etc/apache2/passwd Require user user1 I've also got this in my httpd.conf <Directory /var/www> Options Indexes FollowSymLinks AllowOverride AuthConfig </Directory> .. The site opens normally, end it does not require login/password authentication. However, if I put the same .htaccess file in /var/www/lock and change the line <Directory /var/www> in httpd.conf to <Directory /var/www/lock> the server does require a password when the user enters hostname/lock . How can I lock the whole /var/www ? I would like to provide access to my webserver for some users and would love if each one could make his own locks (using .htaccess) so that I don't have to edit httpd.conf every time, anyone wants to lock some directory. Thanks in advance for helping me. Regards, Beliya |
Got it working
I got /var/www locked by removing the lines I had in httpd.conf and adding the following to ports.conf
<VirtualHost *:80> ServerName hostname ServerAlias hostname DocumentRoot "/var/www" <Directory "/var/www"> Options -Indexes Order allow,deny Allow from all AllowOverride AuthConfig AuthType Basic AuthName "Basic Authentication" AuthUserFile /etc/apache2/passwd Require valid-user </Directory> </VirtualHost> If anyone knows how to make each directory in /var/www locked with basic authentication and .htaccess I will really appreciate it if you share =) I want each user to be able to self-lock his/her files, so that I don't have to touch server main config files every single time. |
"World Famous" htaccess tips and tricks http://corz.org/serv/tricks/htaccess.php
|
How to create two lock files?
I am sorry, I did a wrong post here.
|
Everything works
Hey Habitual. Thanks for that guide, it's a nice one.
I got the things I wanted running. Apparently it didn't worked before because the options were not in <VirtualHost ..> .. </VirtualHost>. I now have the following virtualhost directive in my ports.conf file: <VirtualHost *:80> ServerName host ServerAlias host DocumentRoot "/var/www" <Directory "/var/www"> AllowOverride AuthConfig </Directory> </VirtualHost> The guide also mentions it: You can also make this change inside a virtual host, which would normally be preferable. So I guess.. that's the right way to do it =) Regards, Beliya |
All times are GMT -5. The time now is 01:51 AM. |