I have a set of webservers with nginx acting as a reverse proxy for
tomcat behind an AWS ELB.
Request -> AWS ELB -> Nginx -> Tomcat
To understand if my application is healthy or not I have to send a
request for /status/health. If “health:0” comes back it means the server
is not ready to serve traffic. If “health:1” comes back it means the
server is ready to serve traffic. Unfortunately, in both scenarios the
http response code is always 200. Since AWS ELB has a dumb healthcheck
method I can’t place a server in or out of rotation based on the actual
response output. AWS only considers http response code.
Is it possible to have Nginx modify the http response code based on the
upstream output? I want to basically say if the tomcat response is
“health:0” return an http response code 503.