
How do I access and use dnf command with a web proxy server on a Fedora Linux? How do I configure dnf to use a proxy server only?
Dnf repositories (“repos”) can be accessed through standard proxy servers such as Squid or any other proxy server. You need to configure the proxy server in /etc/dnf/dnf.conffile as follows:
- proxy=http://URL:PORT/ – Proxy serer URL to the proxy server that yum should use. You must set a complete URL, including the TCP port number. If your corporate proxy server requires a username and password, specify these by adding following two settings in dnf.conf file.
- proxy_username=YOUR-PROXY-USERNAME-HERE (optional)- Your proxy server username to use for the proxy URL.
- proxy_password=YOUR-SUPER-secrete-PASSWORD-HERE (optional) – Your proxy server password for this proxy URL.
Configuration: Using dnf with a proxy server
First, login as root user and type (open the Terminal app if you are using GUI based Fedora workstation):
# vi /etc/dnf/dnf.conf
OR
$ sudo vi /etc/dnf/dnf.conf
Add/append/edit the following settings in [main] section:
1 2 3 4 |
proxy=http://proxy.nixpal.com:8080 proxy_username=nixpal proxy_password=YourPassword |
Save and close the file. Here is my complete working config /etc/dnf/dnf.conf file:
1 2 3 4 5 6 7 8 |
[main] gpgcheck=1 installonly_limit=3 clean_requirements_on_remove=true proxy=http://proxy.nixpal.com:8080 proxy_username=nixpal proxy_password=YourPassword |
Please note that defining a proxy server, username, and password in dnf.conf file means all users connect to the proxy server with those details when using dnf command:
# dnf update
# dnf install foo
How do I enable proxy access for a specific user such as root user only?
Type the following command at shell prompt:
# export http_proxy="http://proxy.nixpal.com:8080"
OR
# export http_proxy="http://PROXY=USERNAME=HERE:PROXY=PASSWORD=HERE@URL:PORT"
# export http_proxy="http://nixpal:YourPassword@proxy.nixpal.com:8080"
Feel free to add the above line in the to your shell profile file such as ~/.bash_profile.