Created
February 7, 2009 18:12
-
-
Save thbar/59954 to your computer and use it in GitHub Desktop.
This file contains 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 <%= public_ip %>:80> | |
ServerName <%= server_name %> | |
# server aliases (generated from config) | |
<% ((server_aliases.keys + server_aliases.values).flatten - [server_name]).each do |server_alias| %> | |
ServerAlias <%= server_alias %><% end %> | |
DocumentRoot <%= public_path %> | |
<Directory "<%= public_path %>/"> | |
Options FollowSymLinks | |
AllowOverride None | |
Order allow,deny | |
Allow from all | |
</Directory> | |
RewriteEngine On | |
<Proxy balancer://<%= application %>-mongrels><% start_port.upto(end_port) do |port| %> | |
BalancerMember http://127.0.0.1:<%= port %><% end %> | |
</Proxy> | |
<% server_aliases.keys.each do |server_name| %><% server_aliases[server_name].each do |server_alias| %> | |
# redirect <%= server_alias %> to <%= server_name %> | |
RewriteCond %{HTTP_HOST} <%= server_alias %> | |
RewriteRule (.*) http://<%= server_name %>$1 [L,R=301] | |
<% end %><% end %> | |
Options -MultiViews | |
# redirect assets | |
RewriteCond %{REQUEST_URI} ^/assets/.*$ | |
RewriteCond %{DOCUMENT_ROOT}/assets/%{HTTP_HOST}/$1 -f | |
RewriteRule ^/assets/(.*)$ /assets/%{HTTP_HOST}/$1 [QSA,L] | |
# index redirection | |
RewriteCond %{REQUEST_URI} ^/$ | |
RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}/index.html -f | |
RewriteRule (.*) /cache/%{HTTP_HOST}/index.html [QSA,L] | |
# content redirection | |
RewriteCond %{REQUEST_URI} ^/[^.]+$ | |
RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}%{REQUEST_URI}.html -f | |
RewriteRule (.*) /cache/%{HTTP_HOST}%{REQUEST_URI}.html [QSA,L] | |
# everything else in cache | |
RewriteCond %{REQUEST_URI} ^/.+$ | |
RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}%{REQUEST_URI} -f | |
RewriteRule ^(.*)$ /cache/%{HTTP_HOST}%{REQUEST_URI} [QSA,L] | |
# everything not found goes to Mongrel | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^/(.*)$ balancer://<%= application %>-mongrels%{REQUEST_URI} [P,QSA,L] | |
</VirtualHost> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment