[root@mysql116 nginx]# htpasswd -c /usr/local/nginx/passwd.db vincent
New password:
Re-type new password:
看一下生成的密码文件
然后在nginx的配置中添加两条:
location /{
proxy_pass https://127.0.0.1:5601;
auth_basic "secure";
auth_basic_user_file /usr/local/nginx/passwd.db;
}
重新加载配置文件
[root@mysql116 nginx]#./sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/
nginx.conf test is successful
[root@mysql116 nginx]#./sbin/nginx -s reload