nginx - 在不提供凭据的情况下允许来自 IP 的请求访问 Nginx 失败
问题描述
我正在尝试实现Nginx 白名单,即允许来自某个 IP 地址的用户在不提供凭据的情况下访问 Nginx。
但是,即使我遵循了Nginx 文档,来自该 IP 上的浏览器的请求也会受到用户名/密码的挑战(需要 401 身份验证)。
这是我的配置(在 AWS/EC2 CentOS 7 实例上):
[centos@ip-172-31-94-4 nginx]$ cat /etc/nginx/conf.d/default.conf
server {
location / {
root /usr/share/nginx/html;
index index.html index.htm;
satisfy all;
# Requests from this IP need not supply a password
allow 96.53.xx.xx;
deny all;
# Others should supply username/passwords
auth_basic "Private site";
auth_basic_user_file /etc/nginx/.htpasswd;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ /\.ht {
deny all;
}
}
您能否建议如何让来自 96.53.xx.xx 的 Nginx 请求通过而不会受到用户名/密码的挑战?
编辑:
浏览器缓存和历史被清除并sudo nginx -s reload
执行。
解决方案
更改satisfy all
为后satisfy any
,白名单似乎正在工作。
推荐阅读
- deep-learning - 为什么我们在 ResNet 中使用身份层?
- python - 使用 pandas 将列表列表写入现有 csv 文件
- flutter - 如何将共享功能添加到颤振中的图标[在社交媒体中单击按钮共享应用程序]
- amp-html - 使用 amp-bind 和 amp-mustache 迭代 amp-state
- c - 我试图弄清楚选项#2如何无法运行。C 编程
- python - 如何在不首先构造列表的情况下创建一个 numpy 对象数组?
- reactjs - 当有不同的端点到相同的 url 时,反应 api 响应崩溃
- c - int (*pt)[2] 中的 *pt 和 int *pt 中的 pt 有什么区别?
- ios - Swift 5 iOS13 - Segue 到另一个 Storyboard 或未连接的视图控制器而不创建卡片视图
- c++ - 使用 for_each 和 lambda 来销毁一个同位对象