We at fabulously40.com use nginx with a java backend. When it came to system service updates, We had no efficient way of displaying a "service out of commission" page. Our typical scenario for this was modifying our nginx configuration and restarting the service to redirect users to a "service out of commission page."

Obviously this isn't really ideal, the whole comment, modify and restart httpd cycle. Here is an excellent solution for redirecting users to a service-out-of-commission page dynamically.

      
	location ~ /(javascripts|images|stylesheets|html)/ {
                root /opt/jetty/production/fab40;
       	}
	location / {
		# ... proxy configuration up here...
            	if (-f /opt/jetty/production/fab40/upgrade) {
               	 rewrite ^(.*)$ /html/upgrade.html last;
                	break;
           	}
		# redirect to proxy
	}

Whenever, Nginx sees the "upgrade" file in /opt/jetty/production/fab40 it redirects all users to /html/upgrade.html. As soon as I remove the "upgrade" file nginx redirects traffic back to the proxy for backend requests.

So our typical upgrade scenario goes like this...


	sh# cd /opt/jetty/production/fab40
	sh# cp /export/home/victori/fab40.war .
	sh# unzip fab40.war
	sh# touch upgrade
	sh# svcadm disable jetty; svcadm enable jetty
	# ... wait a few seconds for the backend to startup...
	sh# rm upgrade 

Nice and simple roll out of our service.