Ubuntu – How to configure apt-get to use a Pac file for a proxy

aptPROXY

In my workplace we use the Pac file for proxy network .And the Pac file when i give to the browser setting its work fine Edit–>Advance–>Network–>Setting. When i gave the Url its working fine for me.

But for apt-get i was not able to update.

I added the same URL in the network proxy for that. My pac file have no username or password.

Please suggest me .How should the apt-get work in my new ubuntu 11.10.I am really struggling a lot to fix this issue

Best Answer

I do not know if APT is able to use a PAC file directly but you can (with quite a bit of work/understanding) extract the relevant proxy information from the PAC file itself and use this information to configure APT to use a HTTP proxy.

The PAC file essentially consists of a JavaScript function. The return statement (one or more) of the function returns the proxy server address and port, for example:

return "PROXY proxy.some.site:8080; DIRECT";

Just look at your PAC file by entering its address in a browser. With this information you can create an APT configuration file:

sudo gedit /etc/apt/apt.conf.d/proxy

You should modify the file so that it contains the following information:

Acquire::http::Proxy "http://proxy.some.site:8080";

Save the file and the next apt-get run should use the configured proxy setting.

It would be nice if APT could work with PAC files because we also use them in our company. Perhaps somebody else knows if/how it works...

The Ubuntu Wiki Page for AptGet also has some hints how to configure a proxy for APT.

See also https://superuser.com/questions/323488/ubuntu-system-wide-proxy-auto-configuration-pac-script