Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 12 down vote accepted

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;
  }
}
share|improve this answer
    
thankyou for you reply... can you explain a touch more... currently in the ELB health check I'm pointing it at /index.html. Do you mean point the health checks at say '/elb-status' and the add the above server block? is that it? does the /elb-status url need to exist? thx again –  Adam Jun 25 '13 at 0:52
    
worked perfectly when I put /elb-status in the ELB and added the server block above - thankyou so much!!! greatly apprecated –  Adam Jun 25 '13 at 0:58
    
Glad I could help! –  ceejayoz Jun 25 '13 at 1:26
    
@ceejayoz, that was a clever solution. I spun up an instance that is getting no outside traffic, and one the elb status checks are taken care of, this starts to show up in the log, I think it is the ELB latency checks, any ideas there? 10.244.162.24 - - [26/Dec/2013:06:04:18 +0000] "-" 400 0 "-" "-" –  eezis Dec 26 '13 at 6:14
1  
Hmm, I'm gettting "/usr/share/nginx/html/elb-status" failed (2: No such file or directory)... any idea why this could be? –  Michael Waterfall Jan 24 at 17:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.