# Modify response code based on upstream response

**URL:** <https://www.ruby-forum.com/t/modify-response-code-based-on-upstream-response/232262>\
**Category:** NGINX\
**Created:** [September 28, 2014, 10:51pm UTC](https://www.ruby-forum.com/t/modify-response-code-based-on-upstream-response/232262 "2014-09-28T22:51:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [September 28, 2014, 10:51pm UTC](https://www.ruby-forum.com/t/modify-response-code-based-on-upstream-response/232262/1 "2014-09-28T22:51:53Z")

</div>

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.

–  
Jeremy Piven  
removed\_email\_address@domain.invalid
