auth_basic 认证

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

shell > cd /usr/local/nginx-1.10.2/conf

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

shell > vim /usr/local/nginx-1.10.2/conf/vhost/local.conf

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

 

posted @ 2018-04-26 14:45  L狗哥  阅读(190)  评论(0编辑  收藏  举报