Custom Nginx error pages on upstream responses

Digital Ocean has a great post on setting up error pages when nginx encounters an error. However, the above does not work when a request is successfully passed to an upstream server and the upstream response is a 50x error. When processing the upstream response is desired, proxy_intercept_errors on; must be added to the configuration (thank you Stack Overflow!).

The server block looks like this:

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;


        proxy_intercept_errors on;
        error_page 500 502 503 504 /custom_50x.html;
        location = /custom_50x.html {
                root /usr/share/nginx/html;


InfluxDB on Raspberry Pi

I found a blog post by Aymerick describing how to build InfluxDB on a Raspberry Pi. Here’s what I did to get it working.

Install prerequisites

$ sudo apt-get install -y bison ruby2.1 ruby-dev build-essential
$ sudo gem2.1 install fpm

Install gvm

This installs gvm for the current user:

$ bash < <(curl -s -S -L

Setup Go

$ gvm install go1.4.3
$ gvm use go1.4.3 --default

Create an influxdb package set

$ gvm pkgset create influxdb
$ gvm pkgset use influxdb

Build InfluxDB

$ go get
$ go get
$ cd ~/.gvm/pkgsets/go1.4.3/influxdb/src/
$ gdm restore
$ go clean ./...
$ go install ./...

The ./ command did not work for me, so I settled for the influxd and influx binaries in ~/.gvm/pkgsets/go1.4.3/influxdb/bin.

Mac + Docker Toolbox + HAProxy

Working with Docker Toolbox on a Mac is great. It makes it very easy to work with Docker continers and setting up interconnected services with Docker Compose. However, since the services are running in a virtual machine, accessing the services from a machine other than the Mac itself is not possible out of the box.


Installing and running HAProxy on the Mac will proxy any traffic from the VM to external hosts looking to access the service. I installed haproxy via homebrew with the command brew install haproxy.

With HAProxy installed, I set it up to proxy HTTPS traffic over to the VM. In my case, the VM was and my Mac’s IP was I saved the configuration below at /usr/local/etc/haproxy/haproxy.cfg.

  log  local0
  log  local1 notice
  maxconn  4096
  chroot   /usr/local/share/haproxy
  uid  99
  gid  99

  log   global
  mode  tcp
  option  dontlognull
  retries  3
  option  redispatch
  option  http-server-close
  maxconn  2000
  timeout connect  5000
  timeout client  50000
  timeout server  50000

frontend www_fe

  use_backend www

backend www
  timeout server 30s
  server www1

Launch daemon

With haproxy configured, I placed the launchd configuration at /Library/LaunchDaemons/com.zymbit.haproxy.plist and ran the command sudo launchctl load -w /Library/LaunchDaemons/com.zymbit.haproxy.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Starting and stopping launchd

Now, whenever I want external access to the Docker service I run the command launchctl start com.zymbit.haproxy and when I’m done launchctl stop com.zymbit.haproxy.

Manually booting from a Grub prompt

I installed Ubuntu on a Cisco UCS C250 M2 system with a USB flash drive. The installer attempted installing Grub on the installer drive instead of the system drive. In attempts to have a bootable system, I dropped to a shell and ran:

chroot /target /bin/bash
grub-install /dev/sdb (where sdb is drive you installed on)

The above installed Grub, but didn’t configure it to boot the system. After booting I landed at a grub prompt instead of the system prompt. I was able to boot the system with the steps below.

First, I ran the command below to get the drive’s UUID. Below <tab> is tapping the tab key on the keyboard:

ls (hd0<tab>

This prints out details of the drive; the UUID is needed in the command below.

insmod ext2
set root='hd0,msdos1'
linux /boot/vmlinuz<tab> root=UUID=<insert UUID here>
initrd /boot/initrd<tab>

This properly booted the system. From here, the first thing to do is install Grub properly. Login to the system and run:

grub-install /dev/sda

After a reboot the system booted properly.

Transplant commits with git rebase –onto

You are working along and then realize that all the work you did is based off the wrong branch. Instead of working off the branch wrong-branch, you should have been working off the branch right-branch. What to do?

First, as a safety create a fix branch off your current branch:

git checkout -b fix-topic-branch topic-branch

Now, take a look at the commits to find the ref your work is on top of:

git log --oneline --decorate

8cb0c1a (fix-topic-branch) Added artcode urls
1ff8dac Added art form
0670ee7 added django-resourceful requirement
633dda6 Added ArtView class
e64f05f Added models
4186ba8 Added pristine django app artcode
d49ad49 (wrong-branch) Merge branch 'add-test-finder' into baseline

In the case above the commits we want are on top of d49ad49, which is `wrong-branch`. With this info you can tell git rebase --onto to take all commits “on top of” d49ad49 in fix-topic-branch and plant them on top of right-branch.

git rebase --onto right-branch d49ad49 fix-topic-branch

Once you confirm fix-topic-branch looks as you expect, you can rename it back to topic-branch:

git branch -D topic-branch
git branch -m topic-branch

Fix sync button in GitHub for Windows

My friend Elyse is a chef in Sonoma County. I setup a website for her using Jekyll, GitHub for Windows, and Heroku. When she wants to update her website, she makes changes to Markdown files and clicks the “sync” button in GitHub for Windows to publish her changes. It works magnificently well … until it breaks, and GitHub for Windows is terrible at telling you what the error actually is.

After some searching I discovered the sync button performs two actions:

git pull --rebase
git push

At some point git pull --rebase failed and left behind a .git/rebase-apply directory. In order to fix this, open the shell as the error message suggests and run the command:

del .git/rebase-apply

Confirm that it should remove the entire folder, then close the shell. Retry the sync command and it should work.

Easily escape HTML for a WordPress post

Here’s a one-liner for converting angle brackets and other characters that need escaping. This will work on any system that has Python installed. Run this command:

python -c 'import cgi; import sys; print cgi.escape(' | pbcopy

Once you hit enter on the command above, paste the content to convert and after pasting hit enter followed by ctrl+d.

If you’re not on OS X, remove the pipe to pbcopy. If you are on OS X, your converted text is now in your clipboard!