Skip to content

Instantly share code, notes, and snippets.

@alkalinecoffee
Last active December 20, 2015 23:39
Show Gist options
  • Save alkalinecoffee/6214090 to your computer and use it in GitHub Desktop.
Save alkalinecoffee/6214090 to your computer and use it in GitHub Desktop.
Apache vhost config for Unicorn with whitelisted IPs
<VirtualHost *:80>
ServerName localhost
# ServerAlias www.localhost.com
DocumentRoot /var/www/myrailsapp/current/public
RewriteEngine On
# Redirect all non-static requests to unicorn
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://unicornservers%{REQUEST_URI} [P,QSA,L]
<Proxy balancer://unicornservers>
BalancerMember http://127.0.0.1:8080
# by default, deny everything
order deny,allow
deny from all
# add whitelisted ips and ranges
allow from 127.0.0.1
allow from 192.0.0.0/8
allow from 192.168.1
allow from 192.168.1.100
</Proxy>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment