php56-tls-phpmailer-featured

TLS Peer Verification w/PHP 5.6 and WordPress SMTP Email plugin

We ran into an issue after upgrading from PHP 5.5 to 5.6. We were no longer able to send email via the awesome WordPress SMTP Email plugin. Turns out that PHP 5.6 introduced some enhancements to its OpenSSL implementation. Stream wrappers now verify peer certificates and hostnames by default. This was causing the form submissions on our site to fail. Clearly there are some issues with our Postfix config and certs. While we sort out those issues, we were able to “solve” our immediate problem, and disabled peer verification in the plugin without editing core files. Thankfully the plugin developer included a filter that would allow us to modify the options array that is passed to PHPMailer.

Woot!

Thanks random WordPress forum user for the solution!

nginx-redirects

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 1.2.3.4, $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.