Here is how it is supposed to work.
The simplest case is to set a proxy for apt by editing "/etc/apt/apt.conf" and adding this line:
The problems start if you have a local mirror - I do this to save bandwidth due to a large number of ubuntu installs on the network. For this config, remove any proxy lines from /etc/apt/apt.conf and create /etc/apt/apt.conf.d/30proxy:
With the http_proxy environment variable unset this works fine, until you go to install something like flashplugin-nonfree, which downloads a tarball from adobe. Apt completely ignores your proxy configuration and tries to download it directly:
Connecting to archive.canonical.com|188.8.131.52|:80
Which obviously doesn't work. You can set the http_proxy environment variable, but then apt won't work because it sends everything through the proxy, and the local mirror settings (ubuntu.mydom.com) you have in /etc/apt/sources.list can't go through the proxy (and shouldn't). That's what the "DIRECT" above is supposed to do.
The only way to actually make this work is described by Troy. You need to set the no_proxy environment variable:
Then make sure it actually gets kept by sudo. First get the list of var's sudo is currently preserving (look at those under "Environment variables to preserve"):
sudo sudo -V
Change /etc/sudoers with 'sudo visudo' and add:
Defaults env_keep="no_proxy http_proxy https_proxy ftp_proxy XAUTHORIZATION XAUTHORITY TZ PS2
PS1 PATH MAIL LS_COLORS KRB5CCNAME HOSTNAME HOME DISPLAY COLORS"
Check that it got kept:
sudo printenv | grep no_proxy
Chuck no_proxy and http_proxy in ~/.bashrc and you are good to go. Simple, right?