1 配置文件

server {

        listen       80;
        server_name  status.zyb.com;
        location /status {
                auth_basic "zyb training";      #用户和密码框提示字符
                auth_basic_user_file /application/nginx/conf/htpasswd;    #用户和密码存放的文件
                stub_status on;
                access_log off;
            }

    }


2 配置用户和密码

[[email protected] vhost]# yum install -y httpd

[[email protected] vhost]# which htpasswd
/usr/bin/htpasswd
[[email protected] vhost]# /usr/bin/htpasswd -bc /application/nginx/conf/htpasswd zyb 123456
Adding password for user zyb
[[email protected] vhost]# /application/nginx/sbin/nginx -s reload


3 测试结果

nginx访问认证

相关文章:

  • 2022-03-05
  • 2021-07-10
  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
猜你喜欢
  • 2021-11-27
  • 2021-11-27
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2021-11-08
相关资源
相似解决方案