- apt-get install apache2 -y
- apt-get install libapache2-mod-proxy-html libxml2-dev -y
- a2enmod headers
- a2enmod proxy
- a2enmod proxy_http
- a2enmod proxy_balancer
- a2enmod rewrite
- a2enmod ssl
- /etc/init.d/apache2 restart
<VirtualHost *:80>
ServerName myhost.example.com
DocumentRoot /opt/example/app/public
RewriteEngine On
# Redirect all non-static requests to unicorn
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://unicornservers%{REQUEST_URI} [P,QSA,L]
RewriteCond %{DOCUMENT_ROOT}/public/$0 -f
RewriteRule ^.+\.(jpg|jpeg|gif|png|ico|css|js|swf)$ /public/$0 [L]
<Proxy balancer://unicornservers>
Allow from any
BalancerMember http://127.0.0.1:8080
</Proxy>
</VirtualHost>
Source: