When you’re developing applications for a fortune 50 company, you’re bound to run into a problem with their security focused IT department. Recently, I was having trouble deploying a rails application to a server that was sitting behind a proxy. I tried to solve the problem by changing bundler, then by reconfiguring capistrano, but those were both dead ends.
I thought that I could edit my
.gemrc and that bundler would use those settings, but that didn’t work. I had been installing gems by using the
--http-proxy flag so it seemed like that would work. I had also been contacting the outside world (for git and other things) by setting the
http_proxy environment variable, but I was doing so manually each time I needed it, rather than setting it up in my shell’s rc file. Here’s how I fixed it.
This assumes that the shell you’re editing belongs to the user that deploys the application in capistrano.
1. Add the
http_proxy to your shell’s rc file
# bash export http_proxy=http://proxy.example.com:8080 #tcsh setenv http_proxy http://proxy.example.com:8080
2. Ensure that when you create a new session, the
http_proxy environment variable is actually set
$> echo $http_proxy http://proxy.example.com:8080
Now, when you deploy with capistrano, the
bundle command will the proxy that’s setup and communication with your gem sources won’t timeout.