Nginx – ELB can’t proxy traffic to the EC2 instance

amazon ec2amazon-elbnginx

For some reason ELB isn't correctly forwarding requests to my instance on EC2.

My setup is simply a micro instance with nginx/node, listening on ports 80 and 443. The instance gets the health checker requests through ELB perfectly.

10.185.1.190 – – [01/Oct/2013:15:26:18 +0000] "GET / HTTP/1.1" 302 40 "-" "ELB-HealthChecker/1.0"

10.185.1.190 – – [01/Oct/2013:15:26:48 +0000] "GET / HTTP/1.1" 302 40 "-" "ELB-HealthChecker/1.0"

10.185.1.190 – – [01/Oct/2013:15:27:18 +0000] "GET / HTTP/1.1" 302 40 "-" "ELB-HealthChecker/1.0"

10.185.1.190 – – [01/Oct/2013:15:27:48 +0000] "GET / HTTP/1.1" 302 40 "-" "ELB-HealthChecker/1.0"

10.185.1.190 – – [01/Oct/2013:15:28:18 +0000] "GET / HTTP/1.1" 302 40 "-" "ELB-HealthChecker/1.0"

10.185.1.190 – – [01/Oct/2013:15:28:48 +0000] "GET / HTTP/1.1" 302 40 "-" "ELB-HealthChecker/1.0"

10.185.1.190 – – [01/Oct/2013:15:29:18 +0000] "GET / HTTP/1.1" 302 40 "-" "ELB-HealthChecker/1.0"

10.185.1.190 – – [01/Oct/2013:15:29:48 +0000] "GET / HTTP/1.1" 302 40 "-" "ELB-HealthChecker/1.0"

10.185.1.190 – – [01/Oct/2013:15:30:18 +0000] "GET / HTTP/1.1" 302 40 "-" "ELB-HealthChecker/1.0"

However, requesting it through the browser directly doesn't work at all.

It should be noted that my instance is accessible directly, through its IP. The SG is configured to allow any connections on both ports, and ELB just proxies them to the instance.

ELB reports the instance is Out of Service.

Health Check:

Ping Target: HTTP:80/
Timeout: 5 seconds
Interval: 30 seconds
Unhealthy Threshold: 2
Healthy Threshold: 10

Neither HTTP nor HTTPS work on ELB, and both work on the instance.

Obviously, in my nginx logs I don't get anything when trying to request an ELB instance. curl reports:

HTTP/1.1 503 Service Unavailable: Back-end server is at capacity

Halp

Best Answer

Your server is returning a 302 (redirect) response code, and ELB looks for a 200 response code to consider an instance in service. You need to have healthcheck look at a page that doesn't redirect.

Related Topic