A proxy server is a machine that sits in your network infrastructure with a purpose of translating traffic between networks or protocols. You can think of it as an intermediary server that separates the end-user clients from the destinations that they browse / need to access. There are quite some security features that you get by having a Proxy server in your Infrastructure. A proxy server caches content to reduce bandwidth and load web pages more quickly.
In this article, we show you how to configure system proxy settings on Debian 11/10/9 Linux system for the HTTP, HTTPS, and FTP protocol and when using wget command line tool. Proxy settings can be applied to a particular user account on a Linux system or push settings that affect all logged in users. This can be done on a graphical interface or configuring from the command line.
1) Set System-Wide Proxy settings on Debian from GUI
If you have a Desktop Environment you can set Proxy under Settings > Network > Network Proxy > Manual interface.
Populate proxy values for:
- HTTP Proxy
- HTTPS Proxy
- FTP Proxy
- Socks Host if applicable
- Ignore Hosts – List of destination IP addresses or domain names where Proxy settings should not be applied.
For users using Firefox Web browser, you need to update proxy settings under Preferences > Network Settings > Manual Proxy configuration.
Configure Proxy and click “OK” to save. The settings should take effect immediately after applying them.
2) Set System-Wide Proxy settings on Debian from CLI
For this we will create a file inside /etc/profile.d
directory and set Proxy settings that will work for all users on a Debian Linux system.
sudo vim /etc/profile.d/proxy.sh
Populate your proxy values.
# set proxy config via profie.d - should apply for all users
# http/https/ftp/no_proxy
export http_proxy="http://10.10.1.20:8080/"
export https_proxy="http://10.10.1.20:8080/"
export ftp_proxy="http://10.10.1.20:8080/"
export no_proxy="127.0.0.1,localhost"
# For curl
export HTTP_PROXY="http://10.10.1.20:8080/"
export HTTPS_PROXY="http://10.10.1.20:8080/"
export FTP_PROXY="http://10.10.1.20:8080/"
export NO_PROXY="127.0.0.1,localhost"
Add any additional IP address to be excluded to the NO_PROXY & no_proxy environment variables. When done add execution bit to the script created.
sudo chmod +x /etc/profile.d/proxy.sh
Any user in the system that needs to use these settings have to log out and back in:
logout
Alternatively, source the file for runtime use:
source /etc/profile.d/proxy.sh
Confirm proxy has been loaded in your environment.
$ env | grep -i proxy
3) Set proxy for APT package manager
The Proxy settings in method 1 and 2 will only work for applications and command-line tools connectivity, but not for APT package manage.
If you need to set proxy for the APT package manager, configure like below.
$ sudo vim /etc/apt/apt.conf.d/80proxy
Acquire::http::proxy "http://10.10.1.20:8080/";
Acquire::https::proxy "https://10.10.1.20:8080/";
Acquire::ftp::proxy "ftp://10.10.1.20:8080/";
Replace 10.10.1.20 with the correct IP address for your proxy servers. If Authentication is required, set like this.
Acquire::http::proxy "http://<username>:<password>@<proxy>:<port>/";
Acquire::https::proxy "https://<username>:<password>@<proxy>:<port>/";
Acquire::ftp::proxy "ftp://<username>:<password>@<proxy>:<port>/";
4) Set Proxy for wget CLI only
If you would like to set proxy for use with wget
command line tool, the file to modify is ~/.wgetrc
file.
$ vim ~/.wgetrc
use_proxy = on
http_proxy = http://10.10.1.20:8080/
https_proxy = http://10.10.1.20:8080/
ftp_proxy = http://10.10.1.20:8080/
If you were experiencing connectivity issues as a result of Proxy settings required in your system, you should now be connected. The configurations given should work with any Proxy server and not specific to any type. Below we have links on Squid proxy installation. Feel free to check them out:
- Install and Configure Squid Proxy Server on Ubuntu
- Install and Configure Squid Proxy on CentOS 8 / RHEL 8
- How to setup Squid proxy on Ubuntu / CentOS 7