Nginx

  • Nginx 使用 htpasswd 生成密码认证

    2012-10-08 10:26:58 27481 0 技术文章

    安装 httpd-tools

    yum install -y httpd-tools
    

    htpasswd 命令需要先安装 httpd-tools

    修改 nginx.conf

    # xxx.cuiliang.com
    server {
        listen       80;
        server_name  xxx.cuiliang.com;
        auth_basic "密码提示语";
        auth_basic_user_file /usr/local/nginx/conf/htpasswd.users;
    
        location / {
            //...
        }
    }
    

    使用 htpasswd 生成密码

    htpasswd -b /usr/local/nginx/conf/htpasswd.users
    

    输入密码,再次确认密码,提示成功,OK!

    重启 nginx

    /usr/local/nginx/sbin/nginx -s reload
    

    重启生效