How to set up proxy for yum repository in Linux?


Written by - Deepak Prasad

If your RHEL 7 system is configured and running behind a proxy server then you may have to set up proxy for yum repository to access the repository running behind the proxy server on Red Hat Satellite Network.

How to set up proxy for yum repository in Linux?

 

Set up proxy for yum repository

There are two possible scenarios where you can setup proxy for yum repository.

 

Configure Proxy for All Repository

Now to set up proxy for yum for all the available repositories, you have to modify /etc/yum.conf. Since this is the main configuration file for all the yum repository, adding proxy here will set up proxy for yum for all the available repositories.

To add a proxy for all the available repository modify your /etc/yum.conf file and add below line as highlighted

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
proxy=http://user:password@proxy.example.com:3128

 

Configure Proxy for Individual Repository

To add a proxy for individual repository only, you can directly modify the respective repo file inside /etc/yum.repos.d

# cat /etc/yum.repos.d/yum_repo.repo
[repo_yum]
name=yum_repo
baseurl=http://yumrepo.example.com/os
enabled=1
gpgcheck=0
proxy=http://user:password@proxy.example.com:3128

 

Ignore Proxy for Individual/All Repository

If you specifically want to make sure a repository does not use a proxy then add the below highlighted value in /etc/yum.conf to apply for all the repositories or individual your repo file inside /etc/yum.repos.d

# cat /etc/yum.repos.d/rhel_no_proxy.repo
[repo_yum_no_proxy]
name=yum_repo_no_proxy
baseurl=http://yumrepo.example.com/os
enabled=1
gpgcheck=0
proxy=_none_

 

Lastly I hope the steps from the article to set up proxy for yum repository in Linux was helpful. So, let me know your suggestions and feedback using the comment section.

 

Views: 53

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can reach out to him on his LinkedIn profile or join on Facebook page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

2 thoughts on “How to set up proxy for yum repository in Linux?”

  1. For the life of me I could not get the YUM CLI to add a proxy to /etc/yum.repo.d/*.repo files:

    ~]# yum-config-manager –save –setopt=proxy=http://proxy:3128/ epel

    This works, by adding entries to /etc/yum.conf:

    ~]# yum-config-manager –save –setopt=proxy=http://proxy:3128/ main

    Reply

Leave a Comment