Use a Proxy with Ubuntu APT

If apt-get complains about not being able to reach the mirror server, you maybe are behind a proxy. Apt then just hangs until it shows a connection timeout message.

You can configure a proxy for Apt by adding the folloing line to /etc/apt/apt.conf.d/01proxy.

Acquire::http::Proxy "http://proxyaddressorname:proxyport";

01proxy is a chained config file for Apt and can be created if it doesn’t exist.

After adding the entry, you can test the configuration by running sudo apt-get update. It should work now.

Update 1:
Use the following bash commands to configure a proxy for git:

export http_proxy=http://proxyaddressorname:proxyport
git config --global http.proxy $http_proxy

Update 2:
For easy_install and pip you can get the proxy settings working by exporting a https proxy, which actually is a http proxy.

export https_proxy=http://proxyaddressorname:proxyport