Static error page served by nginx when my application is down

Posted by dreeves on Server Fault See other posts from Server Fault or by dreeves
Published on 2012-06-22T01:34:17Z Indexed on 2012/06/22 3:18 UTC
Read the original article Hit count: 482

Filed under:
|

If my (Rails) application is down or undergoing database maintenance or whatever, I'd like to specify at the nginx level to server a static page. So every URL like http://example.com/* should server a static html file, like /var/www/example/foo.html.

Trying to specify that in my nginx config is giving me fits and infinite loops and whatnot.

I'm trying things like

location / {
  root /var/www/example;
  index foo.html;
  rewrite ^/.+$ foo.html;
}

How would you get every URL on your domain to serve a single static file?

© Server Fault or respective owner

Related posts about nginx

Related posts about url-rewriting