I have a ELB setup in Amazon that's pointing to two servers that are running Nginx. Nginx is then forwarding the request locally to a different port that runs our Node JS application.
As I'm testing for redundancy, if I stop the Node JS application from running, Nginx will return a 502 Bad Gateway which I fully expect. The problem I'm having is how can I have the ELB determine that this is a bad page and that it should stop sending requests to a problematic server? The ELB seems to see the Nginx 502 error as a valid HTTP request and thus won't remove it.
the ELB monitor doesn't show any 500 errors either
EDIT:
Nginx config:
server {
listen 80;
server_name *.domain.com XX.XX.XX.XX;
access_log off;
client_max_body_size 2048M;
rewrite ^(.*) https://$host$1 permanent;
add_header X-Whom USE1A-01;
}
server {
listen 443;
ssl on;
ssl_certificate /ssl.crt;
ssl_certificate_key /ssl.key;
server_name *.domain.com XX.XX.XX.XX;
access_log off;
client_max_body_size 2048M;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $host;
proxy_pass https://127.0.0.1:XXXX;
}
}
What my nginx access log is showing for the health check when the app is NOT running:
10.50.101.244 - - [07/Jan/2014:21:31:24 +0000] "-" 400 0 "-" "-"
10.50.101.244 - - [07/Jan/2014:21:31:34 +0000] "GET /healthCheck HTTP/1.1" 200 151 "-" "ELB-HealthChecker/1.0"
10.50.101.244 - - [07/Jan/2014:21:31:54 +0000] "-" 400 0 "-" "-"
10.50.101.244 - - [07/Jan/2014:21:32:04 +0000] "GET /healthCheck HTTP/1.1" 200 151 "-" "ELB-HealthChecker/1.0"
10.50.101.244 - - [07/Jan/2014:21:32:24 +0000] "-" 400 0 "-" "-"
10.50.101.244 - - [07/Jan/2014:21:32:34 +0000] "GET /healthCheck HTTP/1.1" 200 151 "-" "ELB-HealthChecker/1.0"
10.50.101.244 - - [07/Jan/2014:21:32:54 +0000] "-" 400 0 "-" "-"
10.50.101.244 - - [07/Jan/2014:21:33:04 +0000] "GET /healthCheck HTTP/1.1" 200 151 "-" "ELB-HealthChecker/1.0"
10.50.101.244 - - [07/Jan/2014:21:33:24 +0000] "-" 400 0 "-" "-"
10.50.101.244 - - [07/Jan/2014:21:33:34 +0000] "GET /healthCheck HTTP/1.1" 200 151 "-" "ELB-HealthChecker/1.0