I'm having a trouble trying to implement basic authentication for ELB healthcheck. I've searched quite a bit to figure out the nginx file configuration to avoid 401 error shown below, which ELB returns due to basic authentication
unhealthy in target-group hogehoge due to (reason Health checks failed with these codes: [401])
I've tried to modify nginx.conf so as to avoid it, but it doesn't work.
The code below gives me [emerg] "server" directive is not allowed here
error.
http {
server {
location / {
if (!$http_x_forwarded_for) {
auth_basic 'Please enter ID and password';
auth_basic_user_file /usr/src/redmine/.htpasswd;
}
}
}
}
How can I avoid 401 error by ELB healthcheck due to basic authentication?
Thanks for the help.