Skip to content

Instantly share code, notes, and snippets.

@ethan605
Last active August 12, 2021 13:36
Show Gist options
  • Save ethan605/adbb5cf3fc88b5cbd9b4001edbb4e71e to your computer and use it in GitHub Desktop.
Save ethan605/adbb5cf3fc88b5cbd9b4001edbb4e71e to your computer and use it in GitHub Desktop.

Configurations to make Arch Linux work with proxies

System-wide configs

Append to ~/.zshrc or ~/.bashrc

export http_proxy="http://<proxy-host>:<proxy-port>/"
export https_proxy=$http_proxy
export no_proxy="localhost,127.0.0.1,192.168.1.1,::1,*.local"
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy
export NO_PROXY=$no_proxy

Ref: https://wiki.archlinux.org/title/Proxy_server#Environment_variables

Docker

Append a new proxies field to ~/.docker/config.json:

{
  ...
  "proxies": {
    "default": {
      "httpProxy": "http://<proxy-host>:<proxy-port>/",
      "httpsProxy": "http://<proxy-host>:<proxy-port>/",
      "noProxy": "localhost,127.0.0.1,192.168.1.1,::1,*.local"
    }
  }
}

Notes: Docker proxies don't work with hostname (defined in /etc/hosts)

Ref: https://docs.docker.com/network/proxy/

Git

Append to ~/.ssh/config

Host <vpn-protected-host>
  ProxyCommand ssh -q <username>@<proxy-host> nc %h %p

Ref: https://www.systutorials.com/git-through-ssh-tunnel-as-proxy/

Google Chrome

Create or append to ~/.config/chrome-flags.conf

--proxy-server=<proxy-host>:<proxy-port>

Ref: https://www.mankier.com/1/google-chrome#--proxy-server

Python

Append to ~/.zshrc or ~/.bashrc

export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

Ref: mitmproxy/mitmproxy#2547 (comment)

There need to be some extra steps to get the machine work with mitmproxy, because it uses custom CA certificates to decode the requests.

Notes: I haven't figured out a proper way to make WebSocket connections work under mimtproxy

Install custom CA certificates

Download mitmproxy-ca-cert.pem file from mitmproxy:

$ openssl x509 -in mitmproxy-ca-cert.pem -inform PEM -out mitmproxy.crt
$ sudo trust anchor mitmproxy.crt

Ref: https://gist.github.com/franciscocpg/a4f52afcc00d472a9d7c407db16a92ee

Docker

Copy mitmproxy.crt to the project and prepend to Dockerfile (as root access):

COPY mitmproxy.crt /usr/local/share/ca-certificates
RUN update-ca-certificates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment