wget and apt-get through a proxy
I recently needed to use wget and apt-get from the commandline on a customer’s Debian system but the site only allows internet access via a proxy. To get these very useful tools to play nice with the proxy, I needed to type this command (substituting the correct proxy settings of course):
export http_proxy="http://proxy.mydomain.com:8080/"
Seems simple but easy to get wrong. The quotes are important, the http:// and the trailing slash are also important otherwise apt-get will not work properly. http_proxy must be in lower case which is unusual for an environment variable.
If your proxy needs a login name, do this:
export http_proxy="http://user:password@proxy.mycomain.com:8080/"
There are also ftp_proxy, gopher_proxy and wais_proxy environment variables if you need them but I was only interested in HTTP for this task.
UPDATE – Proxy exceptions
If you don’t want to go through the proxy for certain addresses, use the no_proxy variable. This is a comma-separated list of domains which you do not want resolved via the proxy. Unfortunately wild cards are not supported (so you can’t just put 192.168.* :-( ) and the maximum number of entries in this list is 16. Here is an example:
export no_proxy="192.168.0.1,localdomain"
Of course, the proxy settings will be forgotten when you log out. To make the proxy setting a little more permanent, you can set your proxy variables in /etc/profile

Pingback by Links for 02-Oct-2007 « The Blog That Should Not Be — 2 October 2007 @ 10:21 pm
[...] Posted by Mel on October 2nd, 2007 Adam Pierce » wget and apt-get through a proxy [...]