How can one configure System wide proxy settings on CentOS or Fedora or RHEL or Rocky Linux machine?. Our guide will discuss how you can configure access to internet via proxy server on a Linux machine. This will include the use of wget, lynx, or curl utilities from a command line as well as package management tools.
Configure System-Wide Proxy settings on Desktop UI
For users running a Desktop environment on Fedora / CentOS and RHEL Linux, changes can be made on the system control panel.
Navigate to Settings > Network > Network Proxy

Select “Manual” to input proxy settings.

Populate proxy values for http, https, and ftp. If you have SOCKS proxy, also set it accordingly. Once changes are saved, the system will pick them automatically.
Proxy on Firefox Browser
If you have Firefox browser, you need to update proxy settings under Preferences > Network Settings > Manual Proxy configuration.

Configure Proxy settings and click “OK” to save.
Configure System-Wide Proxy settings on CLI
We will add a shell script file under /etc/profile. This will ensure the settings apply to all logged-in users.
sudo vi /etc/profile
Add your proxy settings.
# set proxy config via profie.d - should apply for all users
#
PROXY_URL="http://10.10.1.10:8080/"
export http_proxy="$PROXY_URL"
export https_proxy="$PROXY_URL"
export ftp_proxy="$PROXY_URL"
export no_proxy="127.0.0.1,localhost"
# For curl
export HTTP_PROXY="$PROXY_URL"
export HTTPS_PROXY="$PROXY_URL"
export FTP_PROXY="$PROXY_URL"
export NO_PROXY="127.0.0.1,localhost"
Where:
- 10.10.1.10 is the proxy server ip, can be replaced with hostname
- 8080 is the proxy server port, if different update it accordingly.
If authentication is required, the syntax is:
http://username:password@proxyserver:proxyport/
Source the file when done to start using the proxy settings, or alternatively logout and back in.
source /etc/profile
Confirm:
env | grep -i proxy
Set proxy for YUM|DNF package manager
The above settings will work for Applications and command-line tools but not for YUM and DNF package management tools.
For DNF – Fedora / CentOS/RHEL 8
$ sudo vim /etc/dnf/dnf.conf
# Add
proxy=http://proxyserver:port
For CentOS 6/7:
$ sudo vim /etc/yum.conf
proxy=http://proxyserver:port
For RHEL users, you’ll also need to set Proxy for accessing RHSM content:
$ sudo vi /etc/rhsm/rhsm.conf
# Configure
proxy_hostname = proxy.example.com
proxy_port = 8080
If your proxy server requires authentication, also set
# user name for authenticating to an http proxy, if needed
proxy_username=
# password for basic http proxy auth, if needed
proxy_password =
That’s the basic settings you’ll need to use proxy server to access internet on CentOS/RHEL 7&8 and on Fedora Linux machines.
For Ubuntu/Debian, check:
# user name for authenticating to an http proxy, if needed
proxy_user =
should be proxy_username =
no?
Correct.
Edwin is correct; it needs to be “proxy_username=”.
Additionally, in the sentence right below the “Configure System-Wide Proxy settings on CLI” section, it says, “We will add a shell script file under /etc/profile.d/proxy.sh”. However, the command shown right afterwards is “sudo vi /etc/profile”. This causes confusion for readers when the command used references a different file than what was specified right before that.
This has been captured correctly in the article. Thanks for the insights
sorry could i ask you to fix?
Thank you so much for teaching. This article help me setup my Cent OS 7.
Thanks for the positive comment.
Hi Josphat, thanks for the article.
I have a few questions that I hope you can clarify.
On my Centos 7 / Rocky servers I have set PROXY_URL=ip_address:8080/ (without http before the ip) and I see that it works, the proxy processes the requests, so the http before the IP address is not imperative?
On Ubuntu I have verified that without http before the IP address it does not work, so you have to put it on.
Furthermore, I also see that both http and https traffic are proxed, even if I have not set the line: https_proxy=http://ip_address:8080/, is this normal behavior?
Many thanks in advance!