小编Sam*_*_TT的帖子

如何避免使用 nginx 配置进行 AWS ELB 运行状况检查的基本身份验证

我在尝试为 ELB 运行状况检查实施基本身份验证时遇到了麻烦。我已经搜索了很多以找出 nginx 文件配置以避免如下所示的 401 错误,这是由于基本身份验证而导致 ELB 返回的

unhealthy in target-group hogehoge due to (reason Health checks failed with these codes: [401])

我试图修改 nginx.conf 以避免它,但它不起作用。下面的代码给了我[emerg] "server" directive is not allowed here错误。

http {
    server {
        location / {
            if (!$http_x_forwarded_for) {
                auth_basic           'Please enter ID and password';
                auth_basic_user_file /usr/src/redmine/.htpasswd;
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

由于基本身份验证,如何避免 ELB 运行状况检查出现 401 错误?

谢谢您的帮助。

passenger nginx amazon-web-services amazon-elb

6
推荐指数
1
解决办法
6589
查看次数