I was working with a barebones Apache setup recently and needed to enable Digest authentication, but it turned out the necessary modules weren’t loaded. After some research, I came up with the below. I’m largely posting this for my own reference, but figured others could benefit as well.
Make sure the module and password file paths are correct!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# BEGIN user auth # load needed modules for Digest if they’re not loaded LoadModule auth_digest_module apache/modules/mod_auth_digest.so LoadModule authn_file_module apache/modules/mod_authn_file.so LoadModule authz_user_module apache/modules/mod_authz_user.so AuthType Digest AuthName “Unauthorized Realm” AuthDigestDomain / AuthUserFile /full/path/to/.htpasswd-digest # absolute path to password file Require user # replace with user who is logging in # you can list multiple exceptions that bypass authentication (remove or comment out if not needed) SetEnvIf Request_URI “/path/to/exception.php$” allow Order allow,deny Allow from env=allow Satisfy any # END user auth |
Leave a Reply