0

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 1.2.3.4:80; }
server {
  listen       1.2.3.5:80;
  server_name  www.example.com;
  root         /var/www/example.com/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;
  }
}

2 Answers 2

7

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..

1

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 ?

2
  • 2
    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
    Commented May 12, 2011 at 19:08
  • 1
    @ColinM nice reply. Commented Jul 29, 2015 at 20:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .