public
Last active

Apache with mongrel_cluster configuration to remember

  • Download Gist
apache_vhost_mongrel_cluster.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
# Apache configuration to remember
 
#NameVirtualHost *:80 # Better in apache2.conf
 
# Fix: "client denied by server configuration"
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
 
# Setup the cluster
<Proxy balancer://foo_cluster>
BalancerMember http://127.0.0.1:8075
BalancerMember http://127.0.0.1:8076
</Proxy>
 
# Setup the VirtualHost for your Rails application
<VirtualHost *:80>
ServerAdmin webmaster@foo.com
ServerName foo.com
ServerAlias *.foo.com
DocumentRoot /home/foo/rails/public
 
<Directory "/home/foo/rails/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
 
# Setup your Rewrite rules here
RewriteEngine On
 
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteCond %{SCRIPT_FILENAME} !\.(js|gif|jpg|png|css)$
RewriteRule ^.*$ /system/maintenance.html [L]
 
# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]
 
# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]
 
# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://foo_cluster%{REQUEST_URI} [P,QSA,L]
 
# Compress common non-binary content.
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpeg|jpg|tiff|tif|png|mov|wmv|mp3|zip)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
 
# Error logs
#RewriteLogLevel 9
#RewriteLog "/usr/local/apache2/logs/foo_rewrite.log"
ErrorLog "/usr/local/apache2/logs/foo_error.log"
CustomLog "/usr/local/apache2/logs/foo_access.log" combined
 
</VirtualHost>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.