Skip to content

Instantly share code, notes, and snippets.

@caok
Created November 13, 2012 13:36
Show Gist options
  • Save caok/4065791 to your computer and use it in GitHub Desktop.
Save caok/4065791 to your computer and use it in GitHub Desktop.
rails-for-apache
<VirtualHost *:80>
ServerName boyu
ServerAlias boyu
# Point this to your public folder of project
DocumentRoot /u/apps/boyu/current/public
ErrorDocument 503 /system/maintenance.html
RewriteEngine On
# Redirect all requests to the maintenance page if present
RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ - [redirect=503,last]
<Proxy balancer://unicornservers>
BalancerMember http://127.0.0.1:10000
</Proxy>
# Redirect all non-static requests to thin
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://unicornservers%{REQUEST_URI} [P,QSA,L]
ProxyPass / balancer://unicornservers/
ProxyPassReverse / balancer://unicornservers/
ProxyPreserveHost on
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
# Custom log file locations
ErrorLog ${APACHE_LOG_DIR}/rails-error.log
CustomLog ${APACHE_LOG_DIR}/rails-access.log combined
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment