Created
November 3, 2011 00:33
-
-
Save bruth/1335433 to your computer and use it in GitHub Desktop.
Dynamic location-based mass hosting approach with maintenance mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
# Define a conventional location for where are apps are deployed | |
# Locations such as "/apps/foo" and "/apps/bar" will match result | |
# in "foo" and "bar", respectively, being the application "names". | |
WSGIScriptAliasMatch ^/apps/([^/]+) /usr/local/srv/apps/$1-env/$1/src/conf/wsgi/app.py | |
# This example derived from deployed multiple Django applications, thus | |
# the static and media directories are mapped here. | |
AliasMatch ^/apps/([^/]+)/static/(.*) /usr/local/srv/apps/$1-env/$1/src/_static/$2 | |
AliasMatch ^/apps/([^/]+)/media/(.*) /usr/local/srv/apps/$1-env/$1/src/media/$2 | |
# A trivial "maintenance mode" solution is to keep a directory around | |
# of static files for displaying a page while in maintenance mode. | |
AliasMatch ^/apps/([^/]+)/maintenance/(.*) /usr/local/srv/apps/$1-env/$1/maintenance/$2 | |
RewriteEngine On | |
# This first set of conditions test whether a "MAINTENANCE_MODE" file | |
# exists in the project root (same where the maintenance directory | |
# lives) and redirects to the static maintenance location. | |
RewriteCond %{REQUEST_URI} ^/apps/([^/]+)/(.*) | |
RewriteCond %2 !^maintenance | |
RewriteCond /usr/local/srv/apps/%1-env/%1/MAINTENANCE_MODE -f | |
RewriteRule ^.*$ /apps/%1/maintenance/ [R,L] | |
# This set of conditions test whether a "MAINTENANCE_MODE" file | |
# does _not_ exist in the project root and redirects to the root | |
# location of the app. | |
RewriteCond %{REQUEST_URI} ^/apps/([^/]+)/maintenance/.* | |
RewriteCond /usr/local/srv/apps/%1-env/%1/MAINTENANCE_MODE !-f | |
RewriteRule ^.*$ /apps/%1/ [R,L] | |
</VirtualHost> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
WSGIScriptAlias / /usr/local/srv/apps/app-env/app/src/conf/wsgi/app.py | |
Alias /static /usr/local/srv/apps/app-env/app/src/_static | |
Alias /media /usr/local/srv/apps/app-env/app/src/media | |
Alias /maintenance /usr/local/srv/apps/app-env/app/maintenance | |
RewriteEngine On | |
RewriteCond %{REQUEST_URI} !^/maintenance/.* | |
RewriteCond /usr/local/srv/apps/app-env/app/MAINTENANCE_MODE -f | |
RewriteRule ^ /maintenance/ [R,L] | |
RewriteCond %{REQUEST_URI} ^/maintenance/.* | |
RewriteCond /usr/local/srv/apps/app-env/app/MAINTENANCE_MODE !-f | |
RewriteRule ^ / [R,L] | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment