centos7 nginx 密码认证

shell > yum -y install httpd-tools  # 安装 htpasswd 工具

shell > cd /etc/nginx/conf.d

shell > htpasswd -c /etc/nginx/cert/pass.db wang # 创建认证用户 wang 并输入密码,添加用户时输入 htpasswd pass.db username 

shell > vim /etc/nginx/conf.d/local.conf

server {
    listen       80;
    server_name  local.server.com;
    
    auth_basic "User Authentication";
    auth_basic_user_file /etc/nginx/cert/pass.db;
    
    location / {
        root   /data/www;
        index  index.html;
    }
}

相关推荐

暂无评论

发表评论

微信扫一扫,分享到朋友圈

centos7 nginx  密码认证