-1

I configured a vhost with http authentication.

ServerAdmin info@example.com ServerName www.example.com DocumentRoot /home/webmaster/www.example.com/

    <Directory "/home/webmaster/www.example.com/">
            Options -Indexes +FollowSymLinks -MultiViews
            AllowOverride All
            Require all granted

            DirectoryIndex index.html, index.php

           AuthType Basic
           AuthName "www.example.com"
           AuthUserFile "/home/webmaster/.htpasswd"
           Require valid-user

    </Directory>


    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/www.example.com-access.log combined
    ErrorLog /var/log/apache2/www.example.com-error.log

/home/webmaster/.htpasswd file was created using htpasswd command:

htpasswd -c /home/webmaster/.htpasswd john

but Apache doesn't prompt for credentials, so users can browse the website without restrictions. No error in Apache error.log file and no errors in www.example.com-error.log file.

any suggestions? many thanks

Piero

1

You need a RequireAll statement.

<directory ...>
...
  <RequireAll>
    Require all granted
    Require valid-user
  </RequireAll>
</directory>

Check article on apache auth

0

still doesn't work :-(

    ServerAdmin info@annunci.net

    ServerName www.mysite.com

    DocumentRoot /home/webmaster/www.mysite.com/

    <Directory "/home/webmaster/www.mysite.com/">
            Options -Indexes +FollowSymLinks -MultiViews
            AllowOverride All
            Require all granted

            DirectoryIndex index.html, index.php
    <RequireAll>

           AuthType Basic
           AuthName "www.mysite.com"
           AuthUserFile "/home/webmaster/.htpasswd"
          Require all granted
          Require valid-user

    </RequireAll>
    </Directory>


    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/www.mysite.com-access.log combined
    ErrorLog /var/log/apache2/www.mysite.com-error.log

  • removing Require all granted solved the problem, thanks to all! – PieroB Dec 2 '16 at 10:21
  • Hi PieroB, could you please edit the "answer" to make it a real answer? – bummi Dec 2 '16 at 12:17

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.