0

I'm currently searching a solution to re-enable basic authentication with .htpasswd file in Apache 2.4. Everything was ok using Apache 2.2 and then I upgraded to MAMP Pro 6.4 that implements Apache 2.4. The authentication is now just ignored.

I understood that the key thing is the Directory content of the httpd.conf file.

Currently, it is configured like that :

<Directory "/Users/Shared/Shared_Items/hostname.domain.eu">  
        Options Indexes Includes FollowSymLinks  
        AllowOverride All  
        Require all granted  
        AuthType Basic  
AuthName "Munki Repository"  
AuthUserFile /Users/Shared/Shared_Items/hostname.domain.eu/munki_repo/.htpasswd    
Require valid-user
</Directory>  

So I just added the 4 latest lines in the GUI and the app creates the whole thing.

I tried many solutions suggested and found nothing that works.

I really doubt that there's a bug in Apache 2.4 that prevents totally the usage of basic authentication.

4
  • 1
    Does it work if you remove Require all granted?
    – digijay
    Jul 19 at 20:02
  • 1
    The Question is a bit ugly formatted, but due to fact, I can't edit as I have too much pending I already added an answer
    – djdomi
    Jul 20 at 14:13
  • @digijay : You genius ! In MAMP Pro, when you unselect the option "(Require) all granted", it changes the line to "Require host localhost". And then the authentication is working as expected ! Many thanks ! Jul 20 at 20:25
  • Glad I could help!
    – digijay
    Jul 20 at 20:35
1

`This is a complete working Virtalhost, you have to adapt it to your Solution.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory "/var/www/html">
        AuthType Basic
        AuthName "Restricted Content"
        AuthUserFile /etc/apache2/.htpasswd
        Require valid-user
    </Directory>
</VirtualHost>
2
  • Thank you also, I have now a straightforward solution but I keep your solution on my notes ! Jul 20 at 20:26
  • if it is solved and I did it not answered, please add on your own the answer and mark it as solution as else the question is open and seeking answers for the next decade
    – djdomi
    Jul 21 at 4:07
0

In MAMP, I disabled the option "Require all granted" as suggested by digijay and then in the configuration file, the option is automatically set to "Require host localhost". Then the basic authentication works from a remote client (not on the server locally but this is ok like that).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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