I need to perform some maintenance, which involves down-times of my EC2 production server. I would like to serve some user friendly Maintenance page meanwhile.
The easiest solution, I was able to come up with, is to grab some minimalistic Micro instance AMI, setup the static page there and associate our public elastic IP to that instance during the maintenance.
The questions are:
(1) Is there an easier way (i.e. to serve some static page from s3, without need for EC2 instance)? [please note, that I don't want any dns caching delays, I prefer immediate switch like with ec2-associate-address]
(2) If there is no easier way, which AMI to start with (so that it can run on micro instance and preferably boots from EBS, so that could be easily persisted)?
Update:
For the record, here is the solution I used:
- Create micro instance from any ami found on http://alestic.com/
- Install nginx:
sudo aptitude install nginx
- Now you can start/stop/restart it using
sudo /etc/init.d/nginx start/stop/restart
- Edit Nginx config file
sudo pico /etc/nginx/nginx.conf
- Instead of the
include /etc/...
row paste the following:
server { root /var/www/nginx-default; location / { if (-f $document_root/error503.html) { return 503; } } # error 503 redirect to error503.html error_page 503 @maintenance; location @maintenance { rewrite ^(.*)$ /error503.html break; }
- Create the page (the folder should already exist)
/var/www/nginx-default/error503.html
and remove the/var/www/nginx-default/index.html
. - Start/Restart Nginx
sudo /etc/init.d/nginx start
- Now you are done and you could use
ec2-associate-address YOUR-IP -i YOUR-INSTANCE-ID
to map your public IP between the production server and this maintenance-page serving instance.