Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there a way to use acquire::http::proxy for some repositories?

I'm in a network that has a proxy server. So everybody has to update /etc/apt/apt.conf adding the lines like

Acquire::http::Proxy "http://yourproxyaddress:proxyport";
Acquire::https::Proxy "http://yourproxyaddress:proxyport";
Acquire::ftp::Proxy "http://yourproxyaddress:proxyport";
Acquire::socks::Proxy "http://yourproxyaddress:proxyport";

Everything working ok with that.

But now we have a LOT of ubuntu machines and I want to do a local ubuntu mirror.

So we should erase those proxy lines.... except for external repositories.

So, how do I configure something like that?

In RH based distros you can have a global proxy setting for yum and then use individual proxy settings for each repository. But didn't found something similar un Ubuntu.

share|improve this question
add comment

2 Answers

This is how I solve this problem.

Remove all the acquire lines in apt.conf and bring it back to it's pristine state

Now, export your http_proxy as

export http_proxy=http://username:password@host:port 
export no_proxy=.xyz.org

where xyz.org is your local domain name

Now finally run apt-get as follows.

sudo -E apt-get update

The -E option make the http_proxy variable available to apt-get. That's it. Proxy is now used for all external connections and not for the internal network.

share|improve this answer
    
This method is not compatible with the rest of the system. –  Gustavo Berman Jan 28 at 17:30
add comment
up vote 0 down vote accepted

Finally I got it working as I wanted.

For every local mirror you have to add a line like this:

Acquire::http::proxy::local.mirror.address "DIRECT";

So, in /etc/apt/apt.conf I got something like:

Acquire::http::Proxy "http://yourproxyaddress:proxyport";
Acquire::http::proxy::local.mirror.address "DIRECT";
Acquire::https::Proxy "http://yourproxyaddress:proxyport";
Acquire::ftp::Proxy "http://yourproxyaddress:proxyport";
Acquire::socks::Proxy "http://yourproxyaddress:proxyport";

That way I can use our web proxy for outside/external repositories and be able to use our local repository mirror without a web proxy.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.