Back

Proxy Inferno

Proxy Inferno

If like me you are or have been confronted with corporate proxies bullshit and whatnot, you might understand this article's title. I cannot even count the amount of time I have lost trying to make things work, fiddling, googling, etc. After running into so many walls, I decided to document my journey through Proxy Hell, one of the missing circles of Hell as described in Dante's Inferno. This list isn't exhaustive but represents the many configurations I had to set up in my former position. Hopefully, it will be of use to you.

apt

Create a new file in /etc/apt/apt.conf.d/ And add the following lines in the file proxy.conf. Create it if it doesn't exist.

Acquire::http::Proxy "http://user:password@proxy.server:port/";
Acquire::https::Proxy "http://user:password@proxy.server:port/";

git

git config --global http.proxy <http://proxyUsername:proxyPassword@proxy.server.com>:port
git config --global https.proxy <https://proxyUsername:proxyPassword@proxy.server.com>:port

npm

npm config set proxy "<http://"username:password"@proxy.big-corp.com>"
npm config set https-proxy "<http://"username:password"@proxy.big-corp.com>"

If you're running nodejs INSIDE a Docker container you might have to set the proxy for the npm running INSIDE the container before running npm install. Otherwise the install just won't work when building your containers.

Dockerfile

FROM node:14.2.0

ARG HTTP_PROXY

WORKDIR /server
COPY package*.json ./
RUN npm config set proxy $HTTP_PROXY
RUN npm install

This line: ARG HTTP_PROXY declares a docker variable that you can pass when building your container. The RUN npm config set proxy $HTTP_PROXY line sets the proxy for the npm instance running in your container.

Edit your docker-compose file

    build:
      context: .
      args:
        HTTP_PROXY: ${HTTP_PROXY}

It has to be under the build section. Here I set the proxy by calling my machine's environment variable. You can also hardcode the proxy value but it's not really safe.

    build:
      context: .
      args:
        HTTP_PROXY: <http://"username:password"@proxy.big-corp.com>

curl

Edit or create the file located at ~/.curlrc And add this line :

proxy = <http://username:password@ip>:port