DEV Community

Cover image for Proxy Inferno
TonyChanel
TonyChanel

Posted on

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/";
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

npm

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

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
Enter fullscreen mode Exit fullscreen mode

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}
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode

curl

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

proxy = <http://username:password@ip>:port
Enter fullscreen mode Exit fullscreen mode

Playwright CLI Flags Tutorial

5 Playwright CLI Flags That Will Transform Your Testing Workflow

  • 0:56 --last-failed
  • 2:34 --only-changed
  • 4:27 --repeat-each
  • 5:15 --forbid-only
  • 5:51 --ui --headed --workers 1

Learn how these powerful command-line options can save you time, strengthen your test suite, and streamline your Playwright testing experience. Click on any timestamp above to jump directly to that section in the tutorial!

Watch Full Video 📹ī¸

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

If this article connected with you, consider tapping ❤ī¸ or leaving a brief comment to share your thoughts!

Okay