Header RSS Feed
 
If you only want to see the articles of a certain category, please click on the desired category below:
ALL Android Backup BSD Database Hacks Hardware Internet Linux Mail MySQL Monitoring Network Personal PHP Proxy Shell Solaris Unix Virtualization VMware Windows Wyse

Use apt behind proxy - but do not use proxy for some repositories (DIRECT)
Friday - Feb 19th 2016 - by - (0 comments)

At work I have the circumstances that some machines in the internal LAN require a forward proxy to be able to access the Internet. This also means that apt needs to pull patches and installations via the proxy.

Setting up the proxy is very easy and you probably know that already. In /etc/apt/apt.conf add:

Acquire::http::Proxy "http://proxy.example.com:8080";
Acquire::https::Proxy "http://proxy.example.com:8080";

Whenever I use apt from now on, it will use the defined proxy. 

But now to the problem: In our Ubuntu setups we usually keep the original /etc/apt/sources.list file which contains the standard Ubuntu repositories (archive.ubuntu.com).
Additionally to this we have added our own internal Ubuntu repository in an additional file /etc/apt/sources.list.d/ourrepo.list.
This repository is hosted internally, so the (public) proxy cannot access our own repo. This causes problems, because apt-get update keeps hanging with the message "Waiting for headers" as soon as the internal repository URL is checked:

root@ubuntu:~# apt-get update
Ign http://ch.archive.ubuntu.com trusty InRelease
Hit http://ch.archive.ubuntu.com trusty-updates InRelease          
Hit http://ch.archive.ubuntu.com trusty-backports InRelease                   
Hit http://ch.archive.ubuntu.com trusty Release.gpg                           
Hit http://ch.archive.ubuntu.com trusty-updates/main Sources                  
Hit http://ch.archive.ubuntu.com trusty-updates/restricted Sources            
Hit http://ch.archive.ubuntu.com trusty-updates/universe Sources              
Hit http://ch.archive.ubuntu.com trusty-updates/multiverse Sources            
Hit http://ch.archive.ubuntu.com trusty-updates/main amd64 Packages           
Hit http://ch.archive.ubuntu.com trusty-updates/restricted amd64 Packages     
Hit http://ch.archive.ubuntu.com trusty-updates/universe amd64 Packages       
Hit http://ch.archive.ubuntu.com trusty-updates/multiverse amd64 Packages     
Hit http://ch.archive.ubuntu.com trusty-updates/main i386 Packages            
Hit http://ch.archive.ubuntu.com trusty-updates/restricted i386 Packages      
Hit http://ch.archive.ubuntu.com trusty-updates/universe i386 Packages        
Hit http://ch.archive.ubuntu.com trusty-updates/multiverse i386 Packages      
Hit http://security.ubuntu.com trusty-security InRelease                      
Hit http://ch.archive.ubuntu.com trusty-updates/main Translation-en           
Hit http://ch.archive.ubuntu.com trusty-updates/multiverse Translation-en     
Hit http://ch.archive.ubuntu.com trusty-updates/restricted Translation-en     
Hit http://ch.archive.ubuntu.com trusty-updates/universe Translation-en       
Hit http://ch.archive.ubuntu.com trusty-backports/main Sources                
Hit http://ch.archive.ubuntu.com trusty-backports/restricted Sources          
Hit http://ch.archive.ubuntu.com trusty-backports/universe Sources            
Hit http://ch.archive.ubuntu.com trusty-backports/multiverse Sources          
Hit http://ch.archive.ubuntu.com trusty-backports/main amd64 Packages         
Hit http://ch.archive.ubuntu.com trusty-backports/restricted amd64 Packages   
Hit http://ch.archive.ubuntu.com trusty-backports/universe amd64 Packages     
Hit http://ch.archive.ubuntu.com trusty-backports/multiverse amd64 Packages   
Hit http://ch.archive.ubuntu.com trusty-backports/main i386 Packages          
Hit http://ch.archive.ubuntu.com trusty-backports/restricted i386 Packages    
Hit http://ch.archive.ubuntu.com trusty-backports/universe i386 Packages      
Hit http://ch.archive.ubuntu.com trusty-backports/multiverse i386 Packages
Hit http://ch.archive.ubuntu.com trusty-backports/main Translation-en         
Hit http://ch.archive.ubuntu.com trusty-backports/multiverse Translation-en   
Hit http://ch.archive.ubuntu.com trusty-backports/restricted Translation-en   
Hit http://ch.archive.ubuntu.com trusty-backports/universe Translation-en     
Hit http://ch.archive.ubuntu.com trusty Release                               
Hit http://ch.archive.ubuntu.com trusty/main Sources                          
Hit http://ch.archive.ubuntu.com trusty/restricted Sources                    
Hit http://ch.archive.ubuntu.com trusty/universe Sources                      
Hit http://ch.archive.ubuntu.com trusty/multiverse Sources                    
Hit http://ch.archive.ubuntu.com trusty/main amd64 Packages                   
Hit http://ch.archive.ubuntu.com trusty/restricted amd64 Packages             
Hit http://ch.archive.ubuntu.com trusty/universe amd64 Packages               
Hit http://ch.archive.ubuntu.com trusty/multiverse amd64 Packages             
Hit http://ch.archive.ubuntu.com trusty/main i386 Packages                    
Hit http://ch.archive.ubuntu.com trusty/restricted i386 Packages              
Hit http://ch.archive.ubuntu.com trusty/universe i386 Packages                
Hit http://ch.archive.ubuntu.com trusty/multiverse i386 Packages              
Hit http://ch.archive.ubuntu.com trusty/main Translation-en                   
Hit http://ch.archive.ubuntu.com trusty/multiverse Translation-en             
Hit http://ch.archive.ubuntu.com trusty/restricted Translation-en             
Hit http://ch.archive.ubuntu.com trusty/universe Translation-en               
Ign http://ch.archive.ubuntu.com trusty/main Translation-en_US                
Hit http://security.ubuntu.com trusty-security/main Sources                   
Ign http://ch.archive.ubuntu.com trusty/multiverse Translation-en_US          
Ign http://ch.archive.ubuntu.com trusty/restricted Translation-en_US          
Ign http://ch.archive.ubuntu.com trusty/universe Translation-en_US
Hit http://security.ubuntu.com trusty-security/restricted Sources 
Hit http://security.ubuntu.com trusty-security/universe Sources    
Hit http://security.ubuntu.com trusty-security/multiverse Sources        
Hit http://security.ubuntu.com trusty-security/main amd64 Packages
Hit http://security.ubuntu.com trusty-security/restricted amd64 Packages
Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
Hit http://security.ubuntu.com trusty-security/multiverse amd64 Packages      
Hit http://security.ubuntu.com trusty-security/main i386 Packages             
Hit http://security.ubuntu.com trusty-security/restricted i386 Packages       
Hit http://security.ubuntu.com trusty-security/universe i386 Packages         
Hit http://security.ubuntu.com trusty-security/multiverse i386 Packages       
Hit http://security.ubuntu.com trusty-security/main Translation-en            
Hit http://security.ubuntu.com trusty-security/multiverse Translation-en      
Hit http://security.ubuntu.com trusty-security/restricted Translation-en      
Hit http://security.ubuntu.com trusty-security/universe Translation-en        
Ign http://repo.internal.local trusty InRelease                                     
Ign http://repo.internal.local trusty-proposed InRelease
Ign http://repo.internal.local trusty-security InRelease
Ign http://repo.internal.local trusty-updates InRelease
Ign http://repo.internal.local trusty Release.gpg
100% [Waiting for headers]^C

Ever heard of the terminology RTFM? In the man page of apt.conf there is actually the following information written down:

http::Proxy is the default http proxy to use. It is in the standard form of http://[[user][:pass]@]host[:port]/. Per-host proxies can also be specified by using the form http::Proxy:: with the special keyword DIRECT meaning to use no proxies. The "http_proxy" environment variable will override all settings.

This means that by using the DIRECT keyword a defined URL (in this case the URL of our internal repository) can be accessed directly without using the defined proxy. Let's do this!

cat /etc/apt/apt.conf
Acquire::http::Proxy "http://proxy.example.com:8080";
Acquire::https::Proxy "http://proxy.example.com:8080";
Acquire::http::Proxy::repo.internal.local DIRECT;

 Another run of apt-get update now works fine:

root@ubuntu:~# apt-get update
Ign http://repo.internal.local trusty InRelease
Hit http://repo.internal.local trusty-proposed InRelease                        
Hit http://repo.internal.local trusty-security InRelease                         
Hit http://repo.internal.local trusty-updates InRelease                              
Hit http://repo.internal.local trusty Release.gpg                                    
Hit http://repo.internal.local trusty Release                                        
Hit http://repo.internal.local trusty-proposed/main amd64 Packages                   
Hit http://repo.internal.local trusty-proposed/multiverse amd64 Packages             
Hit http://repo.internal.local trusty-proposed/restricted amd64 Packages             
Hit http://repo.internal.local trusty-proposed/universe amd64 Packages               
Hit http://repo.internal.local trusty-proposed/main i386 Packages                    
Hit http://repo.internal.local trusty-proposed/multiverse i386 Packages              
Hit http://repo.internal.local trusty-proposed/restricted i386 Packages              
Hit http://repo.internal.local trusty-proposed/universe i386 Packages                
Hit http://repo.internal.local trusty-proposed/main Translation-en                   
Hit http://repo.internal.local trusty-proposed/multiverse Translation-en             
Hit http://repo.internal.local trusty-proposed/restricted Translation-en             
Hit http://repo.internal.local trusty-proposed/universe Translation-en               
Hit http://repo.internal.local trusty-security/main amd64 Packages                   
Hit http://repo.internal.local trusty-security/multiverse amd64 Packages             
Hit http://repo.internal.local trusty-security/restricted amd64 Packages             
Hit http://repo.internal.local trusty-security/universe amd64 Packages               
Hit http://repo.internal.local trusty-security/main i386 Packages                    
Hit http://repo.internal.local trusty-security/multiverse i386 Packages              
Hit http://repo.internal.local trusty-security/restricted i386 Packages              
Hit http://repo.internal.local trusty-security/universe i386 Packages                
Hit http://repo.internal.local trusty-security/main Translation-en                   
Hit http://repo.internal.local trusty-security/multiverse Translation-en             
Hit http://repo.internal.local trusty-security/restricted Translation-en             
Hit http://repo.internal.local trusty-security/universe Translation-en               
Hit http://repo.internal.local trusty-updates/main amd64 Packages                    
Hit http://repo.internal.local trusty-updates/multiverse amd64 Packages              
Hit http://repo.internal.local trusty-updates/restricted amd64 Packages              
Hit http://repo.internal.local trusty-updates/universe amd64 Packages                
Hit http://repo.internal.local trusty-updates/main i386 Packages                     
Hit http://repo.internal.local trusty-updates/multiverse i386 Packages               
Hit http://repo.internal.local trusty-updates/restricted i386 Packages               
Ign http://ch.archive.ubuntu.com trusty InRelease                              
Hit http://repo.internal.local trusty-updates/universe i386 Packages                 
Hit http://repo.internal.local trusty-updates/main Translation-en       
Hit http://repo.internal.local trusty-updates/multiverse Translation-en
Hit http://repo.internal.local trusty-updates/restricted Translation-en              
Hit http://repo.internal.local trusty-updates/universe Translation-en                
Hit http://repo.internal.local trusty/main amd64 Packages                            
Hit http://repo.internal.local trusty/multiverse amd64 Packages                      
Hit http://repo.internal.local trusty/restricted amd64 Packages                      
Hit http://repo.internal.local trusty/universe amd64 Packages                        
Hit http://ch.archive.ubuntu.com trusty-updates InRelease                      
Hit http://repo.internal.local trusty/main i386 Packages                             
Hit http://repo.internal.local trusty/multiverse i386 Packages                       
Hit http://repo.internal.local trusty/restricted i386 Packages                       
Hit http://repo.internal.local trusty/universe i386 Packages                         
Hit http://repo.internal.local trusty/main Translation-en                            
Hit http://ch.archive.ubuntu.com trusty-backports InRelease                    
Hit http://repo.internal.local trusty/multiverse Translation-en                      
Hit http://repo.internal.local trusty/restricted Translation-en                      
Hit http://ch.archive.ubuntu.com trusty Release.gpg                            
Hit http://ch.archive.ubuntu.com trusty-updates/main Sources                   
Hit http://ch.archive.ubuntu.com trusty-updates/restricted Sources             
Hit http://ch.archive.ubuntu.com trusty-updates/universe Sources               
Hit http://repo.internal.local trusty/universe Translation-en                        
Hit http://ch.archive.ubuntu.com trusty-updates/multiverse Sources             
Hit http://ch.archive.ubuntu.com trusty-updates/main amd64 Packages            
Ign http://repo.internal.local trusty/main Translation-en_US                         
Ign http://repo.internal.local trusty/multiverse Translation-en_US                   
Ign http://repo.internal.local trusty/restricted Translation-en_US                   
Hit http://ch.archive.ubuntu.com trusty-updates/restricted amd64 Packages      
Ign http://repo.internal.local trusty/universe Translation-en_US                     
Hit http://ch.archive.ubuntu.com trusty-updates/universe amd64 Packages        
Hit http://ch.archive.ubuntu.com trusty-updates/multiverse amd64 Packages
Hit http://ch.archive.ubuntu.com trusty-updates/main i386 Packages        
Hit http://ch.archive.ubuntu.com trusty-updates/restricted i386 Packages  
Hit http://ch.archive.ubuntu.com trusty-updates/universe i386 Packages  
Hit http://ch.archive.ubuntu.com trusty-updates/multiverse i386 Packages
Hit http://ch.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://ch.archive.ubuntu.com trusty-updates/multiverse Translation-en
Hit http://ch.archive.ubuntu.com trusty-updates/restricted Translation-en
Hit http://ch.archive.ubuntu.com trusty-updates/universe Translation-en
Hit http://ch.archive.ubuntu.com trusty-backports/main Sources      
Hit http://ch.archive.ubuntu.com trusty-backports/restricted Sources
Hit http://ch.archive.ubuntu.com trusty-backports/universe Sources  
Hit http://ch.archive.ubuntu.com trusty-backports/multiverse Sources
Hit http://ch.archive.ubuntu.com trusty-backports/main amd64 Packages
Hit http://ch.archive.ubuntu.com trusty-backports/restricted amd64 Packages
Hit http://ch.archive.ubuntu.com trusty-backports/universe amd64 Packages
Hit http://ch.archive.ubuntu.com trusty-backports/multiverse amd64 Packages
Get:1 http://security.ubuntu.com trusty-security InRelease [65.9 kB]
Hit http://ch.archive.ubuntu.com trusty-backports/main i386 Packages           
Hit http://ch.archive.ubuntu.com trusty-backports/restricted i386 Packages     
Hit http://ch.archive.ubuntu.com trusty-backports/universe i386 Packages       
Hit http://ch.archive.ubuntu.com trusty-backports/multiverse i386 Packages     
Hit http://ch.archive.ubuntu.com trusty-backports/main Translation-en          
Hit http://ch.archive.ubuntu.com trusty-backports/multiverse Translation-en
Hit http://ch.archive.ubuntu.com trusty-backports/restricted Translation-en
Hit http://ch.archive.ubuntu.com trusty-backports/universe Translation-en
Hit http://ch.archive.ubuntu.com trusty Release                     
Hit http://ch.archive.ubuntu.com trusty/main Sources                 
Hit http://ch.archive.ubuntu.com trusty/restricted Sources
Hit http://ch.archive.ubuntu.com trusty/universe Sources            
Hit http://ch.archive.ubuntu.com trusty/multiverse Sources          
Hit http://ch.archive.ubuntu.com trusty/main amd64 Packages         
Hit http://ch.archive.ubuntu.com trusty/restricted amd64 Packages   
Hit http://ch.archive.ubuntu.com trusty/universe amd64 Packages     
Hit http://ch.archive.ubuntu.com trusty/multiverse amd64 Packages   
Hit http://ch.archive.ubuntu.com trusty/main i386 Packages          
Hit http://ch.archive.ubuntu.com trusty/restricted i386 Packages   
Hit http://ch.archive.ubuntu.com trusty/universe i386 Packages     
Get:2 http://security.ubuntu.com trusty-security/main Sources [105 kB]
Hit http://ch.archive.ubuntu.com trusty/multiverse i386 Packages               
Hit http://ch.archive.ubuntu.com trusty/main Translation-en                    
Hit http://ch.archive.ubuntu.com trusty/multiverse Translation-en  
Hit http://ch.archive.ubuntu.com trusty/restricted Translation-en  
Get:3 http://security.ubuntu.com trusty-security/restricted Sources [4,035 B]
Hit http://ch.archive.ubuntu.com trusty/universe Translation-en                
Get:4 http://security.ubuntu.com trusty-security/universe Sources [33.0 kB]
Get:5 http://security.ubuntu.com trusty-security/multiverse Sources [2,767 B]  
Ign http://ch.archive.ubuntu.com trusty/main Translation-en_US                 
Ign http://ch.archive.ubuntu.com trusty/multiverse Translation-en_US
Ign http://ch.archive.ubuntu.com trusty/restricted Translation-en_US
Ign http://ch.archive.ubuntu.com trusty/universe Translation-en_US
Get:6 http://security.ubuntu.com trusty-security/main amd64 Packages [421 kB]
Get:7 http://security.ubuntu.com trusty-security/restricted amd64 Packages [13.0 kB]
Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [124 kB]
Get:9 http://security.ubuntu.com trusty-security/multiverse amd64 Packages [4,990 B]
Get:10 http://security.ubuntu.com trusty-security/main i386 Packages [393 kB]
Get:11 http://security.ubuntu.com trusty-security/restricted i386 Packages [12.7 kB]
Get:12 http://security.ubuntu.com trusty-security/universe i386 Packages [124 kB]
Get:13 http://security.ubuntu.com trusty-security/multiverse i386 Packages [5,164 B]
Hit http://security.ubuntu.com trusty-security/main Translation-en    
Hit http://security.ubuntu.com trusty-security/multiverse Translation-en
Hit http://security.ubuntu.com trusty-security/restricted Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Fetched 1,307 kB in 5s (231 kB/s)            
Reading package lists... Done

 

 

Add a comment

Show form to leave a comment

Comments (newest first):

No comments yet.

Go to Homepage home
Linux Howtos how to's
Monitoring Plugins monitoring plugins
Links links

Valid HTML 4.01 Transitional
Valid CSS!
[Valid RSS]

6939 Days
until Death of Computers
Why?