Using a proxy is always a pain, but can be done. Since every application or desktop manage proxies another way, it can become really annoying. One way to do it, I’ll show you. In the next few sections I’ll show all my current known locations of proxy settings 😄.

Environment variables

If you’re the single user of your machine or want to set these settings for the machine, you should add these new variables to your /etc/environment:

http_proxy=http://myproxy.server.com:8080/
https_proxy=http://myproxy.server.com:8080/
ftp_proxy=http://myproxy.server.com:8080/
no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
HTTP_PROXY=http://myproxy.server.com:8080/
HTTPS_PROXY=http://myproxy.server.com:8080/
FTP_PROXY=http://myproxy.server.com:8080/
NO_PROXY="localhost,127.0.0.1,localaddress,.localdomain.com"

You might ask, why both in small and capital letters? It happens that some applications seem to use small letters and some capital letters and won’t work if they aren’t defined as expected.

If you don’t want those settings for all users, adding shown variables to the .bashrc, .profile or .zshrc file in your users home folder is the preferred solution.

Too keep those variables also in sudo sessions, we need to add following lines to the /etc/sudoers file:

# Keep Proxy Params in sudo session
Defaults        env_keep+="http_proxy"
Defaults        env_keep+="HTTP_PROXY"
Defaults        env_keep+="https_proxy"
Defaults        env_keep+="HTTPS_PROXY"
Defaults        env_keep+="ftp_proxy"
Defaults        env_keep+="FTP_PROXY"
Defaults        env_keep+="no_proxy"
Defaults        env_keep+="NO_PROXY"

otherwise these variables aren’t set in sudo sessions and might give you “Connection refused” exceptions.

APT

On Debian/Ubuntu based Linux distributions, apt uses a different way to define proxy settings. Even variables in /etc/environment aren’t used in older versions of apt-get.

To use apt with a proxy, create a new file /etc/apt/apt.conf.d/95proxies with:

Acquire::http::proxy "http://myproxy.server.com:8080/";
Acquire::https::proxy "https://myproxy.server.com:8080/";
Acquire::ftp::proxy "ftp://myproxy.server.com:8080/";

GTK3 Programs

GTK 3 Programs like Rythmbox use different settings, which you can set with these commands:

gsettings set org.gnome.system.proxy mode 'manual' 
gsettings set org.gnome.system.proxy.http host 'myproxy.server.com'
gsettings set org.gnome.system.proxy.http port 8080

Docker

If you are using a Linux system with systemd, you can edit the systemd definition of docker and add the variables to the service:

sudo systemctl edit docker

now add:

[Service]
Environment="HTTP_PROXY=http://myproxy.server.com:8080/"
Environment="HTTPS_PROXY=http://myproxy.server.com:8080/"

and depending on which EDITOR you’ve set a :wq or Ctrl+O, Ctrl+X and restart the service

sudo systemctl restart docker

Update Feb 2. 2019: Docker has an own page for setting proxies: Docker Daemon - HTTP Proxy