Tim's Blog

How to setup Basic Auth password authentication for NGINX

Create a *.htpasswd file. Eg: touch /etc/nginx/conf.d/nginx.htpasswd Add an user to the file: echo -n 'user1' >> ./nginx/nginx.htpasswd Generate a password to the user using openssl ultility: openssl passwd -apr1 >> ./nginx/nginx.htpasswd The above command will prompt

Testing NGINX config

To test Nginx config: nginx -t To test a specific config file: nginx -t -c /etc/nginx/sites-enabled/example.com

Tim's Blog © 2026