1. When to use it
Useful for technical folders, internal panels, or temporary tests where a simple explicit barrier is enough.
apache | basic auth | htpasswd | directory | access control
2. Base setup
htpasswd -c /etc/httpd/.htpasswd admin
cat >> /etc/httpd/httpd.conf <<'EOF'
<Directory "/srv/httpd/secure">
AuthType Basic
AuthName "Restricted"
AuthUserFile /etc/httpd/.htpasswd
Require valid-user
</Directory>
EOF
apachectl configtest
Adjust host names, IPs, interfaces, paths, and versions to the real system before making the change persistent.
3. Quick verification
curl -I http://127.0.0.1/secure/
curl -u admin:password -I http://127.0.0.1/secure/
grep -n 'AuthType Basic' /etc/httpd/httpd.conf
Confirm that the output matches the expected state before considering the intervention complete.
4. Operational notes
Basic Auth without HTTPS exposes recoverable credentials: use it only behind TLS or inside a lab.
Quick checklist
[ ] Steps completed\n[ ] Config updated\n[ ] Tests executed\n[ ] Rollback ready\n[ ] Logs checked