Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running Magento (ecommerce PHP app) behind nginx as a reverse proxy to Apache which is running the PHP app. Static content is served directly by nginx. Magento has a "maintenance mode" which uses a 503 HTTP response. With my configuration when maintenance mode is enabled nginx returns a blank page with a 500 response instead of Magento's nice maintenance mode page with the 503 response. How can I make nginx let the 503 page pass through to the client?

Here is my nginx config:

upstream examplecluster       { server; }
server {
  root         /var/www/;

  # security
  location ~ (/(app/|includes/|lib/|pkginfo/|var/|report/config.xml|downloader/(pearlib|template|Maged)/)|/\.svn/|/\.ht.+) {
    return 404;

  location ~ \.php$ {
    proxy_pass http://examplecluster;
    proxy_redirect default;

  # static content
  location / {
    try_files $uri @apache;
    expires 7d;

  # Apache
  location @apache {
    proxy_pass http://examplecluster;
    proxy_redirect default;
share|improve this question
up vote 3 down vote accepted

Turns out there was truly an error while serving the 503 page so nginx was forwarding the response correctly afterall.

However, the relevant nginx setting is proxy_intercept_errors off; which is already the default..

share|improve this answer

I know this is an rather old thread. - But why don't you just let nginx serve both static and dynamic content ?

I mean, nginx is already a webserver that can be used for running the magento application. And you have already configured it for handling the static content. It would be easy to let it handle the dynamic contant as well right ?

share|improve this answer
Mainly because we have been using Apache a long time and it is reliable and I am comfortable with the configuration, and we have a lot of htaccess stuff that would need to be changed and a lot of legacy applications on the server that have never been used with anything but Apache. Also, I don't know how well Magento has been tested under fastcgi and I don't want to be a guinea pig on a production server. – ColinM May 12 '11 at 19:08
@ColinM nice reply. – user973810 Jul 29 '15 at 20:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.