# Unexpected error response

**URL:** <https://www.ruby-forum.com/t/unexpected-error-response/197638>\
**Category:** NGINX\
**Created:** [October 18, 2010, 2:34am UTC](https://www.ruby-forum.com/t/unexpected-error-response/197638 "2010-10-18T02:34:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [October 18, 2010, 2:34am UTC](https://www.ruby-forum.com/t/unexpected-error-response/197638/1 "2010-10-18T02:34:07Z")

</div>

I’m using Nginx as a front end proxy and have some config that checks  
for a file called /maintenance.html and shows that if it’s present.

As our app is quite Ajaxy I would like return a 503 status when the  
/maintenance.html page is served up so that the client app can do some  
smarts to make things a bit more friendly for the end user.

This is the config that I currently have:

```auto
recursive_error_pages on;

location / {
  return 503;
  error_page 503 @tryMaintenance;
}

location @tryMaintenance {
  try_files /maintenance.html /tomcat_stopped.html
@resetResposeCodeAndForwardToRevolve;
}
location @resetResposeCodeAndForwardToRevolve {
  return 400;
  error_page 400 = @forwardToRevolve;
}

location @forwardToRevolve {
  proxy_pass http://revolve:2080;
  error_page 502 504 @serverDown;
}

location @serverDown {
  rewrite .* /server_down.html;
}
```

However when the maintenance.html file is not present I end up getting  
the generic Nginx 503 error rather than the request getting forwarded on  
to my backend server as I expected.

So I guess my question is - is this a bug or am I simply pushing the  
boundaries of what is possible using error\_page as a flow control  
mechanism?

As an aside if I modify the location @tryMaintenance to the following,  
the config does work even though they are basically the same.

```auto
location @tryMaintenance {
  try_files /maintenance.html /tomcat_stopped.html =400;
        error_page 400 = @forwardToRevolve;
}
```

Thanks

Oliver

Posted at Nginx Forum:

> **[Unexpected error response](https://forum.nginx.org/read.php?2,141722,141722#msg-141722)**
>
> I'm using Nginx as a front end proxy and have some config that checks for a file called /maintenance.html and shows that if it's present. As our app is quite Ajaxy I would like return a 503 status when the /maintenance.html page is served up so that...
