Example setup for Apache Site Maintenance pages for proxied applications
Create a directory in /etc/httpd/conf called scontrol owned by root and another subdirectory called control owned by the account apache runs as.
/etc/httpd/conf/scontrol/control
in /etc/httpd/conf/scontrol create the following files owned by root
myapp_inet_set_default.sh
#!/bin/shcd /etc/httpd/conf/scontrolln -sf control/myapp.default.conf myapp.conf/etc/init.d/httpd reload
myapp_inet_set_offline.sh
#!/bin/shcd /etc/httpd/conf/scontrolln -sf control/myapp.offline.conf myapp.conf/etc/init.d/httpd reload
in the control subfolder create the following files owned by the account apache runs under
myapp.default.conf
RewriteRule /myapp$ /myapp/ [R,L]<Location "/myapp/">ProxyPass http://myapp.sysxperts.com:8080/myapp/ProxyPassReverse http://myapp.sysxperts.com:8080/myapp/ProxyPassReverse /</Location>
myapp.offline.conf
RewriteRule ^/myapp/? http://www.sysxperts.com/main/myappmaintenance.html [NC,R,L]
Create the myappmaintenance.html page and put it into the main subfolder that you created under your Document Root or anywhere you'd like to configure it to go provided you use an appropriate RewriteRule.
In the vhost configuration under /etc/httpd/conf/sites/www.sysxperts.com.conf find the Rewrite and Location entries for the app and replace them with:
Include conf/scontrol/myapp.conf
Create a cron job under root to turn on site maintenance page at start of maintenance and one to turn the app back on at end or manually run the scripts as necessary
28 19 * * * /etc/httpd/conf/scontrol/myapp_inet_set_offline.sh
0 0 * * * /etc/httpd/conf/scontrol/myapp_inet_set_default.sh
This example turns on site maintenance page at 7:28PM and brings the app back online at midnight.
No comments:
Post a Comment