Whitelist IPs in Nginx

I want to whitelist my clients IP addresses (and my office IPs) to allow them to view a site, while the rest of the world will be redirected to another site, using Nginx. My Nginx server is behind a load balancer.

Using the geo module I am able to do this rather easily. By default, geo will use $remote_addr for the IP address. However, because our server is behind a load balancer this will not work, as it would always be the IP of the load balancer. You can pass in a parameter to geo to specify where it should get the IP value. In this case, we want to get the IP from $http_x_forwarded_for.

What this is doing is assigning the variable $redirect_ips the value after the IP address. So, if my IP is, $redirect_ips will have a value of 0, or false. If my ip is not matched, it will get the default value of 1, or true;

Ok, with that, my server directive now looks like:


Disable annoying OS X Dock multi-monitor support

I do not like the dock popping up on my second monitor. OS X has a feature where you can mouse over the bottom edge on the screen that doesn’t have the dock and the dock will move there. I can see it being a good feature for some, but I find it to be super annoying. So, here is how you disable this shit:


Capistrano tasks for Magento

Custom tasks for Capistrano that I am using to help manage a Magento website.

Save this as mage.cap and put it under lib/capistrano/tasks/. Then in your Capfile add the following to load your custom tasks.

Now you can reindex the site, clear caches, put site into maintenance mode.