【发布时间】:2015-10-28 04:55:17
【问题描述】:
我的 nginx 指令:
location / {
index index.html index.php;
auth_basic "Members Only";
auth_basic_user_file /var/www/clients/client1/web1/web/.htpasswd_stats;
}
location ~ \.php$ {
allow 1.2.3.4;
allow 127.0.0.1;
deny all;
auth_basic "Members Only";
auth_basic_user_file /var/www/clients/client1/web1/web/.htpasswd_stats;
}
location /dir/ {
auth_basic off;
}
我使用 'auth_basic off' 选项从 htpasswd 检查中排除 'dir' 目录。
当我尝试访问 http://domain/dir/ 时,我看到了除 php 文件之外的所有文件,因为前面的指令要求我进行身份验证。
在 apache 上,我使用“满足任何”选项,但如果我在 nginx 上使用此选项,则对我不起作用或者我放置的站点不正确。
我的目标是当我访问http://domain/dir/ 时,任何文件都没有身份验证。
谢谢!!
【问题讨论】: