Reference:https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/
Requirements: apache2-utils or httpd-tools
Use htpasswd utility and create a .htpasswd file, see reference\
htpasswd -c /etc/nginx/.htpasswd usernamethatyouwant
chmod 644 /etc/nginx/.htpasswd
After that, just add lines in nginx conf
| |
Restart nginx now or test first using “nginx -t”