Generate an HTTP Authorization: Basic header and an .htpasswd {SHA} entry locally in your browser.
HTTP Basic Authentication (defined in RFC 7617) is the simplest built-in mechanism for protecting staging sites, admin dashboards, metrics endpoints, and internal APIs directly at the web-server layer without touching application code. When a client sends a request, it includes an Authorization: Basic <token> header where the token is the Base64 encoding of username:password.
Authorization: Basic ... header into Postman, Insomnia, curl -H "Authorization: Basic ...", or automated smoke tests. Because Basic Auth transmits credentials in reversible Base64, always use it over HTTPS in production.auth_basic_user_file) and Apache (AuthUserFile) support username:{SHA}<base64-sha1> lines. Everything in this tool is computed locally in your browser using the Web Crypto API (crypto.subtle.digest), so your passwords never leave your device.In Nginx, save the generated .htpasswd line to /etc/nginx/.htpasswd (readable by the www-data or nginx user with chmod 640) and add the following inside a server or location block:
auth_basic "Restricted Area";auth_basic_user_file /etc/nginx/.htpasswd;
In Apache, place a .htaccess file in the protected directory with AuthType Basic, AuthName "Restricted", AuthUserFile /path/to/.htpasswd, and Require valid-user.
Authorization: Basic header can decode it immediately. Always enforce TLS/HTTPS and HSTS when using Basic Auth outside localhost..htpasswd file.{SHA} is natively supported across Nginx, Apache, and lightweight proxies (like Caddy or Traefik) and computes deterministically in pure browser Web Crypto without heavy WASM bundles. For high-security multi-user servers, you can also generate salted bcrypt hashes on the server with htpasswd -B.location = /healthz { auth_basic off; } block so load balancers can probe your app without credentials.After reloading Nginx (nginx -t && systemctl reload nginx) or updating .htaccess, verify that unauthenticated requests return 401 Unauthorized with a WWW-Authenticate: Basic header, and that passing your generated header (curl -i -H "Authorization: Basic ..." https://example.com/) returns 200 OK. If you still see 403 Forbidden, double-check file permissions on the .htpasswd file so the web server worker user can read it.