apt-get http_proxy overwrites Acquire::http::Proxy settings

Bug #365570 reported by Tim Schofield on 2009-04-23
50
This bug affects 7 people
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Undecided
Unassigned
Nominated for Lucid by Greg

Bug Description

Binary package hint: apt

apt-get overrides apt.conf proxy settings with the http_proxy enviroment variable. This is counter intuitive as you would expect application level settings to override system/user settings.

This means I cannot use apt helper programs like apt-cacher or apt-p2p when I have the proxy set in System->Preferences->Network Proxy

Can there be a apt.conf setting which overides this behaviour (so as not to break existing configs)

ProblemType: Bug
Architecture: i386
Dependencies:
 libgcc1 1:4.3.3-5ubuntu4
 gcc-4.3-base 4.3.3-5ubuntu4
 libstdc++6 4.3.3-5ubuntu4
 findutils 4.4.0-2ubuntu4
 libc6 2.9-4ubuntu6
DistroRelease: Ubuntu 9.04
NonfreeKernelModules: nvidia
Package: apt 0.7.20.2ubuntu6
ProcEnviron:
 PATH=(custom, no user)
 LANG=en_GB.UTF-8
 SHELL=/bin/bash
SourcePackage: apt
Uname: Linux 2.6.28-11-generic i686

Changed in apt (Ubuntu):
status: New → Confirmed
SteveLoughran (steve-loughran) wrote :

Seen this too. It also surfaces in synaptic, where the proxy settings in the GUI are ignored in favour of http_proxy.

Apoorv Parle (apparle) wrote :

Facing this problem also
why should apt see http_proxy when it is specified in apt.conf??

Claudiux (claudiux) wrote :

I have the same problem.

For all users of the computer, a proxy is indicated in the http_proxy environnement variable. They enter a pair of id/pwd, in a pop-up authentication window, then they want to view some web page with Firefox.
http_proxy=http://ip_proxy:port/

For apt-get, I put in the /etc/apt/apt.conf file a line as :
Acquire::http::Proxy "http://an_id:a_pwd@ip_proxy:port/";
(with rights 640, root as owner, admin as group ; also, other users can't see the content of this file).

Cause this bug, this config don't works.

Jens Grassel (jan0sch) wrote :

When using the $http_proxy variable I've seen that apt-get does not work at all.
If I do "export http_proxy=localhost:8888" I get an error message telling me "Could not connect to 8888:80" and if I set this to "http://localhost:8888" I get an "open (11 Resource temporarily unavailable)" error.

Greg (g6) wrote :

The http_proxy environment variable in Ubuntu overrides the APT proxy settings. This problem was fixed in Debian in Jan 2009 (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=157759). The apt configuration is more specific, and should win out over the environment variable. This is mainly only a problem for people who run local mirrors, but it is really annoying. This post: http://ilostmynotes.blogspot.com/2010/02/howto-set-proxy-for-apt-updates.html covers the problem in more detail and describes the sucky work around.

Josef Wolf (jw-raven) wrote :

An additional annoyance is if the admin user don't use gnome (e.g. on a server) and don't have a .gconf directory. In this case, an error mail is generated every day even if you don't use a proxy at all. If you have lots of servers, it gets _very_ annoying.

Eric Angell (some-other-guy) wrote :

I've long had a setup with an Acquire::http::proxy directive in /etc/apt/apt.conf.d/18proxy to provide the details of the apt-cacher proxy that my laptop accesses when at work. When I travel, it is extremely handy to be able to run 'http_proxy=DIRECT sudo apt-get whatever' and override the Acquire::http::proxy directive. http_proxy is one of the only environment variables that sudo is willing to pass along, which is perfect.

Then I upgraded from Intrepid to Lucid and this behavior is no longer respected. sudo no longer passes http_proxy, and even if I sudo -s myself a root shell, apt-get no longer respects DIRECT as an override for Acquire::http::proxy. The only way I've found around this so far is to edit /etc/apt/apt.conf.d/18proxy and comment out the line, then run my installation or upgrades, then edit the file again when I take the laptop back to work.

So I'm not sure about the complaints listed in this bug. I think I've had the opposite experience. And regardless of that, I consider the reported behavior to be correct, not buggy. Environment variables _should_ override static config files.

Michael Jones (jonesmz) wrote :

@Eric Angell,

Respectfully, I disagree. I am in the process of setting up 10 Ubuntu servers for various tasks. My company has a site wide proxy, and this is the ONLY way to get a connection into or out of the building for all protocols and ports. (There are various reasons for this, and it isn't something I can change or even recommend changing. I have to deal with it).

As such, to provide a convenient environment on my servers, I have configured them with the http_proxy environment variable, and everything works great. The only thing that does NOT work the way that it should is apt. I have 10 servers. Each of which are configured to pull updates daily. While that isn't a huge amount of data to download, it is enough that I'd much rather have a local mirror. Towards that end, I've installed apt-cacher-ng. I set the proxy information in /etc/apt/apt.conf.d, as this is the only program out of all the dozens of programs on the machine that I DON'T want talking to the company proxy.

The environment variable should be for the general purpose usage of the system. In the general case, all programs should direct their web traffic through the server listed in the http_proxy environment variable. However, any program that has been given a specific proxy to follow in its own local configuration system should do so.

So since apt overwrites its internally configured proxy with the global environment proxy, and apt clearly ignores the no_proxy environment variable (I have tested this throughly. Apt is clearly ignoring no_proxy), I am left few options (suggestions welcome here...) other than to configure each application on each server to use the corporate proxy, and then configure apt to use the apt-cacher-ng proxy, as opposed to configuring the system wide variable and then apt.

In effect, this behavior is causing me a lot of unnecessary work.

Julian Andres Klode (juliank) wrote :

(natty)root@jak-thinkpad:/home/jak# http_proxy=http://10.3.3.3/ apt-get update
W: Failed to fetch http://localhost:3142/ubuntu/dists/natty/Release.gpg Could not resolve 'ip_proxy'

As you can see, the http_proxy variable is ignored.

Changed in apt (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.