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!
# 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
AuthName “Unauthorized Realm”
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
Allow from env=allow
# END user auth
Leave a Reply