# Heroku Behind a Proxy

#### Tuesday, 2012 November 06

If you ever needed to develop for Heroku from behind a proxy server, you may have encountered the problem of not being able to log in, even with export http_proxy statements in your bash_profile. Part of the problem is that the Heroku client uses HTTPS to log in remotely.

To work around this, you can use ProxyChains to tunnel HTTPS connections through your restrictive proxy server. Its role is to provide proxy authentication services for software that otherwise cannot work with proxies.

These instructions have only been tested with Mac OS 10.6.8 and ProxyChains 3.1.

## Installation

1. Download the source files for proxychains-3.1.

2. Whenever I work with source files, I always put them in a certain folder to keep things clean. In this case, I saved proxychains‑3.1.tar.gz in ~/dev/proxychains.

3. Unpack the archive

$cd ~/dev/proxychains$ tar xvzf proxychains-3.1.tar.gz

4. If you're on Mac OS X, you'll need to patch the source in order to compile it. Download the patch from chrootlabs.

5. From the directory above your source tree, patch the source.

$cd ~/dev/proxychains$ patch -p0 < proxychains-3.1_osx.diff

6. Configure the source tree. The prefix option is where make install will copy the built files.

$cd ~/dev/proxychains/proxychains-3.1$ ./configure --prefix=/Users/Kit/dev/build/proxychains

7. Compile and install

$make$ make install


## Setup

1. In order to run proxychains from anywhere, you'll need to create a symbolic link in /usr/local/bin.

$cd /usr/local/bin$ ln -s /Users/Kit/dev/build/proxychains/bin/proxychains proxychains

2. Tweak the proxychains script a little bit.

$cd ~/dev/build/proxychains/bin$ vim proxychains


Look for the line that says

export DYLD_INSERT_LIBRARIES=./.libs/libproxychains.3.0.0.dylib


and change it to

export DYLD_INSERT_LIBRARIES=~/.libs/libproxychains.3.0.0.dylib

3. Copy the library file to the correct folder referenced in the previous step.

$cd ~$ mkdir .libs
$cd ~/dev/build/proxychains$ cp lib/libproxychains.3.0.0.dylib ~/.libs


## Proxy server setup

1. Copy the proxychains.conf file to your home directory.

$cd ~$ mkdir .proxychains
$cd ~/dev/build/proxychains$ cp etc/proxychains.conf ~/.proxychains

2. Configure the proxy server address.

$cd ~/.proxychains$ vim proxychains.conf


Comment out the following line so that it looks like

#proxy_dns


Towards the end of the file, below the header [ProxyList], add your proxy server in the following format

type host port [user pass]


For example

http 12.34.56.78 8080 user_me pa55w0rd

3. In your bash_profile or bashrc, delete or comment out any export statements that set the proxy server for the terminal session. For example

#export http_proxy="http://user:pass@host.com:8080"

4. Test your setup with Heroku

$cd$ proxychains heroku login


## Other use cases

This blog is set up so that images are served from my Dropbox account. Therefore, during development, I will still need an Internet connection. Before I discovered ProxyChains, my images would not load during development because my code cannot contact Dropbox through the proxy server. This time, I can start up my development server with the following line, and any outgoing connections are taken care of by ProxyChains.

\$ proxychains foreman start