Configure Proxy for APT – How to Set Up a Proxy for APT

apt

I need to configure proxy. There wasn't apt.conf file in etc/apt/ so I've created it using nano.

But I don't understand what I need to write there. I've written
http_proxy = http://lgn:pwd@192.168.1.254:8080/ there and then restarted networking. But when I try to apt-get update – it doesn't work.

Actually I don't understand what port and ip I should write in apt.conf file(there was example with 192.168.1.254 ip and 8080 port so I decided to use them).

Best Answer

To use a proxy, you need a proxy server. The IP and port have to be from this proxy server. Login and pwd must be your user and password on the proxy server (if the proxy requires login).

From help.ubuntu.com site:

APT configuration file method

This method uses the apt.conf file which is found in your /etc/apt/ directory. This method is useful if you only want apt-get (and not other applications) to use a http-proxy permanently.

On some installations there will be no apt-conf file set up. Edit apt-conf file (or create a new one if you have no one yet) using the editor of your choice.

sudo nano /etc/apt/apt.conf

Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).

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

Save the apt.conf file.

If your proxy needs a login/password, substitute:

"http://yourproxyaddress:proxyport";

with:

"http://username:password@yourproxyaddress:proxyport";

using username and password from the proxy server.

Related Question