- Install
apache2-utils
(Debian, Ubuntu) or httpd-tools (CentOS) - Run:
htpasswd -c /etc/nginx/.htpasswd [USER]
1
and type password for this user
- Update nginx location config:
location /admin {
auth_basic "Administrator’s Area";
auth_basic_user_file /etc/nginx/.htpasswd;
}
location /not_admin {
auth_basic off;
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
- Reload nginx:
nginx -s reload
1
Comment