18

Is it possible to specify domain for which yum should bypass proxy configuration ? I'm afraid this is not possible...

I read that it was possible to use the environment variable HTTP_PROXY then NO_PROXY, is it the most elegant solution?

[EDIT]

I tried the solution with the environment variables:

export HTTP_PROXY=http://user:pass@host:port
export http_proxy=http://user:pass@host:port
export no_proxy=.domain
export NO_PROXY=.domain

Yum uses proxy but the repos *.domain are not bypassed.

[WORKAROUND]

Using http://cntlm.sourceforge.net/ I can configure which domain should be ignore. But this wotks only with proxy that requires NTLM authentication...

6 Answers 6

40

I have not been able to get this to work using environment variables as you describe here. Yum does support proxies itself, however, and you should be able to do something like this:

proxy=http://proxy:port

Into yum.conf and then adding

proxy=_none_

Into the repo definitions you don't want to access via the global proxy. This is detailed (albeit succinctly) in the yum.conf man page.

3
  • Successful, finally. Thanks! I don't want to go through all the hosts again where I did it. But would it also be possible to add the proxy directly to these repo files where it is needed (e.g. all repos with external package servers, in contrast to the repo files that use internal package managers which don't need proxy)
    – erikbstack
    Jun 27, 2018 at 12:06
  • 1
    proxy=_none_ Brilliant, thanks. That is a ship load of awesome sauce. I'd up-vote you twice if I could :)
    – Scottie H
    Feb 26, 2019 at 0:41
  • @erikbwork I just added a proxy=http://proxy:port to my .repo file and it worked. Is that what you are asking?
    – Scottie H
    Feb 26, 2019 at 0:44
6

If I understand this question correctly the desired behaviour is

packages.centos.com gets pulled via a proxy.

packages.internal.lan goes direct without going via the proxy.

I've just arrived here having googled how to do this myself, and used the above info to achieve what I wanted, however I'm not sure if the above answer is complete.

To do this I used the following.

export HTTP_PROXY=http://myproxy.internal.lan:port

export no_proxy=internal.lan

yum install package1 package2

package1 got pulled from the internet via the proxy,

package2 got pulled from my local mirror not going through the proxy.

5

The replacement of yum on fedora is dnf.

For dnf _none_ will cause an error

You'll need to set proxy to an empty string instead

proxy=

Reference: https://dnf.readthedocs.io/en/latest/conf_ref.html

2
3

My solution involves setting up Privoxy, a light http proxy.

yum install privoxy

Add two forward clauses in /etc/privoxy/config :

 forward / myproxy.internal.lan:3128
 forward .internal.lan .

And also disable privoxy's default actions (ensure no header got corrupted) : (@line 175 in RHEL5 privoxy config)

#actionsfile standard  # Internal purpose, recommended
#actionsfile default   # Main actions file
#actionsfile user      # User customizations

Then setting up http_proxy and ftp_proxy environment variable to privoxy's port:

declare -x http_proxy=http://127.0.0.1:8118

declare -x ftp_proxy=http://127.0.0.1:8118

yum install package1 package2

Note: if you have proxy lines in yum.conf, remove it, it would override the environment variable.

1
  • I was looking for ways to whitelist hosts from privoxy and I've got my answer here :) Jan 13, 2019 at 13:33
2

You can just specify it in the repo file. For example:

[hduser@n0 cloudera-manager-installer]$ cat /etc/yum.repos.d/cloudera-cdh4.repo  
[cloudera-cdh4]  
name=Cloudera's Distribution for Hadoop, Version 4  
baseurl=http://"yourhost"/cdh4/  
gpgcheck = 0
enabled=1
proxy=_none_
0
0

proxy=none within repo definition didn't work on RHEL7.9, it was still referring to the proxy specified in yum.conf, but adding the specific proxy worked. so in my case a specific outbound proxy which allows os updates is specified within yum.conf and have an internet enabled outbound proxy specified using proxy=http://proxy_ob:port within the specific repos

1
  • 1
    Welcome to Super User! Before answering an old question having an accepted answer (look for green ✓) as well as other answers ensure your answer adds something really new or is otherwise helpful in relation to them. Here is a guide on How to Answer. There is also tour for the site tour, and help center for the help center. Feb 10, 2021 at 11:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .