Nginx AWS ELB Health Checks – Return 200 Without IF

amazon ec2amazon-elbamazon-web-servicesnginx

I have the following code that is working on Nginx to keep the AWS ELB healthcheck happy.

map $http_user_agent $ignore {
  default 0;
  "ELB-HealthChecker/1.0" 1;
}

server {
  location / {
    if ($ignore) {
      access_log off;
      return 200;
    }
  }
}

I know the 'IF' is best avoided with Nginx and I wanted to ask if someone would know how to recode this without the 'if'?

thankyou

Best Answer

Don't overcomplicate things. Just point your ELB health checks at a special URL just for them.

server {
  location /elb-status {
    access_log off;
    return 200;
  }
}
Related Topic