如何在 nginx 中禁用特定 ip 范围的 http 基本身份验证?

VoY*_*VoY 31 nginx web-server ip-address http-basic-authentication

我正在开发一个使用 facebook 登录的应用程序。到目前为止,它不是公开的,并且受 nginx 中的 http 基本身份验证保护。是否可以禁用 facebook ip 范围的 http auth,以便我们的测试人员也可以测试 facebook 功能?如果可能,请包含示例配置片段。

oos*_*hro 65

使用满足指令允许访问。32934是facebook自治系统,看facebook ip

satisfy  any;
allow 66.220.144.0/20;
allow 66.220.152.0/21;
allow ...
deny   all;

auth_basic            "closed site";
auth_basic_user_file  conf/htpasswd;
Run Code Online (Sandbox Code Playgroud)

  • 如果您在代理后面,您可能还需要在服务器直接设置真实 ip,即`set_real_ip_from 0.0.0.0/0; real_ip_header X-Forwarded-For;` (2认同)