nginx设置指定访问使用auth_basic
server {
listen 80;
server_name domain.com;
location ^~ /test/ {
auth_basic off;
allow all;
}
auth_basic "登录";
auth_basic_user_file /path/auth.password;
上面这段配置指定了/test/
开头的链接不进行auth_basic验证,里面需要配置auth_basic off
和allow all
。
密码文件生成
htpasswd -bc /path/test.auth.password testuser testpassword
如果提示htpasswd命令不存在则需要安装
apt install apache2-utils
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
评论已关闭