Archive
words and words and words
Technology
[windows] Configuring ruby/git to work behind a proxy

While I develop on OS X, and by preference deploy on Unix/Linux machines, for some of our clients we have to deploy on Windows servers. An IT-department will only allow machines/OSes they can manage themselves. While there are some drawbacks to this, most of them can be worked around perfectly.

One of this those "difficulties" is configuring a proxy. In general, on Windows configuring a proxy means: opening Internet Explorer/IE Edge, editing the connection details and adding/configuring the proxy (I find this completely baffling, did Microsoft not get some kind of anti-trust lawsuit because of the too tight coupling of Internet Explorer and Windows OS? anyways ... old news probably).

Git/ssh

To make sure git (using ssh) uses the proxy correctly, you have to open your $HOME/.ssh/config file, and add at the top:

 ProxyCommand /bin/connect.exe -H 10.52.111.111:80 %h %p
 
 Host github.com 
     [...snipped..]

you can also add the proxy configuration for each Host separately, but in my most cases you will want to use a shared/general proxy (I guess). Replace the shown IP-address with your proxy obviously.

Ruby

For ruby it is actually quite simple: you have to define the environment variable http_proxy (I define it as lower case, I think upper case should also work, but not entirely sure).

[add screenshot]

Javascript

We also run some puppeteer scripts from ruby, and to configure the proxy there, so in a puppeteer script, when creating the browser we have to hand down the proxy details. E.g. something like:

const browser = await puppeteer.launch({
    args: [
        '--proxy-server=10.52.111.111:80',
        '--proxy-bypass-list=localhost,10.200.*.*',
        '--no-sandbox',
        '--disable-setuid-sandbox',
        '--ignore-certificate-errors',
    ]
});
const page = await browser.newPage();
More ...