nginx Maintenance Page for Rails

Wednesday, August 12th, 2009

I recently moved one of my main Rails projects from a Mongrel/Pound stack to Thin and nginx. During this process, I was attempting to set up a maintenance page that would display whenever Thin was offline, but there appears to be some confusion on this topic. Below you will find my minimal solution for displaying a maintenance page for an nginx based rails deployment.

nginx conveniently supplies an error_page configuration option which can be used to specify an html page to be displayed whenever certain errors occur. When the proxied server is offline, such as when Thin or Mongrel is restarting, or you have it stopped while performing maintenance, nginx will return a generic “502 Bad Gateway” error. To replace this page with your own more aesthetically pleasing version, simply place an html file in the public directory of your rails app, and then place this line somewhere in the server section of the nginx config file for the site (which should reside in /etc/nginx/sites-available).

error_page 502 /offline.html;

Simply replace offline.html with the name of your error page, restart nginx, and you’ll be good to go. Here is a bit more context from the configuration file.

server {
  listen 80;

  error_page 502 /offline.html;

  location / {

Moving Oversized Windows in KDE or Gnome

Wednesday, November 9th, 2005

Just a quick little trick that a friend told me which I wanted to write down before I forgot it.

To move a window that is too big for the screen, hold down Alt and then click and drag the window.