Welcome Guest | Login

Selective Maintenance Page when using Mongrel Cluster

In some rare instances, I need to have my site down for a period of time so I can make changes that can only happen in the production environment.  So, what I need is for people who are not coming from my IP address to be shown a maintenance page while my IP gets access to the site.

This is done quite easily via the .htaccess file when running of FastCGI.  

...
#maintenance section
RewriteCond %{REQUEST_FILENAME} !-f
#home ip is 123.123.123.123
RewriteCond %{REMOTE_HOST} !^123\.123\.123\.123
#office ip is 123.123.123.124
RewriteCond %{REMOTE_HOST} !^123\.123\.123\.124
RewriteRule $ /maintenance.html [R=302,L]
...
If I had to go into maintenance mode, I could just uncomment those couple of lines and it worked flawlessly.  However, now that we've moved to a mongrel cluster the .htaccess file is ignored and I can't simply change the rewrite.

I realize that if this were a permanent situation I could have HostingRails add it to the VHost file.  However, this it the sort of thing that might be needed at random times for random intervals and that doesn't seem like the best solution.

Is there another way to easily accomplish this same thing?

I've thought about doing it programatically in Rails by uncommenting a before function that would serve a particular controller action if you weren't coming from the right address.  I'm wary of that because I want to serve a 302 redirect code for any passing spiders.

Any ideas?

2007-08-16 01:27 PM

Doing this programatically in Rails is the best way to go in your situation.  You shouldn't worry about bots or anything (302 is default for redirect_to in Rails). You'll just need to expire all your cached pages and send all traffic to your maintenance page.  

2007-08-17 06:53 PM

I actually mis-typed and should have put 307 (Temporary redirect).  

I worked with this programmatically yesterday but ran into some other things WRT the mongrel setup that had to be fixed first and was able to fix all of it without needing to work behind the scenes on the production server.  However, I do have a maintenance function setup and ready to go (but I had forgotten to have it expire the cached pages - thanks!).  Now at least it is all ready to go for next time.

2007-08-17 07:05 PM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!