我想为nginx做一个复杂的配置:
deny all;
)allow 10.0.1.0/24;
)satisfy all; deny all; allow 10.0.2.0/24;
)我想编写如下配置文件,但当然它有错误,因为satisfy
只能出现一次。
location / {
satisfy any;
allow 10.0.1.0/24; # allowed to access freely
deny all;
satisfy all; ### ERROR
allow 10.0.2.0/24; # allowed to access, with basic auth
auth_basic "closed site";
auth_basic_user_file "closed.htpasswd";
# proxy to somewhere
http://localhost:10081;
}
我如何达到这个要求?
谢谢,
答案 0 :(得分:0)
自我回答(部分)
我可以接受为这种情况修改server
指令配置,因此以下配置看起来正常工作
server {
listen 80;
# server directive allows only these two networks
allow 10.0.1.0/24;
allow 10.0.2.0/24;
deny all;
location / {
satisfy any;
# here comes the two networks above, so I can rely on "satisfy any"
allow 10.0.1.0/24;
deny all;
auth_basic "closed site";
auth_basic_user_file "closed.htpasswd";
proxy_pass http://localhost:10081;
}
}
我希望有更直截了当的方式。