auth_basic 认证

贺俊楚
2023-12-01
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;
    }
}

 

转载于:https://www.cnblogs.com/gouge/p/8952293.html

 类似资料: