apt-cacher-ng
About
Installation
1 aptitude install apt-cacher-ng
To announce to the network with zeroconf
1 aptitude install avahi-daemon
Management
Once installed you can perform management tasks via:
http://localhost:3142/acng-report.html
apt-cacher-ng listens on all interfaces …
Configuration
Server
/etc/apt-cacher-ng/acng.conf
1 # Letter case in directive names does not matter. Must be separated with colons.
2 # Valid boolean values are a zero number for false, non-zero numbers for true.
3
4 CacheDir: /var/cache/apt-cacher-ng
5
6 # set empty to disable logging
7 LogDir: /var/log/apt-cacher-ng
8
9 # TCP (http) port
10 # Set to 9999 to emulate apt-proxy
11 Port: 3142
12
13 # Addresses or hostnames to listen on. Multiple addresses must be separated by
14 # spaces. Each entry must be associated with a local interface. DNS resolution
15 # is performed using getaddrinfo(3) for all available protocols (i.e. IPv4 and
16 # IPv6 if available).
17 #
18 # Default: not set, will listen on all interfaces.
19 #
20 # BindAddress: localhost 192.168.7.254 publicNameOnMainInterface
21
22 #Proxy: http://www-proxy.example.net:80
23 #proxy: http://username:proxypassword@proxy.example.net:3128
24
25 # Repository remapping. See manual for details.
26 # In this example, backends file is generated during package installation.
27 #Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian
28 Remap-debrep: file:deb_mirrors*.gz /debian ; file:backends_debian
29 Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu
30 Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol
31
32 # Virtual page accessible in a web browser to see statistics and status
33 # information, i.e. under http://localhost:3142/acng-report.html
34 ReportPage: acng-report.html
35
36 # Socket file for accessing through local UNIX socket instead of TCP/IP. Can be
37 # used with inetd bridge or cron client.
38 # SocketPath:/var/run/apt-cacher-ng/socket
39
40 # Forces log file to be written to disk after every line when set to 1. Default
41 # is 0, buffer flush happens after client disconnects.
42 #
43 # (technically, this is an alias to the Debug option provided for convenience)
44 #
45 # UnbufferLogs: 0
46
47 # Set to 0 to store only type, time and transfer sizes.
48 # 1 -> client IP and relative local path are logged too
49 VerboseLog: 0
50
51 # Don't detach from the console
52 # ForeGround: 0
53
54 # Store the pid of the daemon process therein
55 PidFile: /var/run/apt-cacher-ng/pid
56
57 # Forbid outgoing connections, work around them or respond with 503 error
58 # offlinemode:0
59
60 # Forbid all downloads that don't run through preconfigured backends (.where)
61 #ForceManaged: 0
62
63 # Days before considering an unreferenced file expired (to be deleted).
64 # Warning: if the value is set too low and particular index files are not
65 # available for some days (mirror downtime) there is a risk of deletion of
66 # still usefull package files.
67 ExTreshold: 4
68
69 # Stop expiration when a critical problem appeared. Currently only failed
70 # refresh of an index file is considered as critical.
71 #
72 # WARNING: don't touch this option or set to a non-zero number.
73 # Anything else is DANGEROUS and may cause data loss.
74 #
75 # ExAbortOnProblems: 1
76
77 # Replace some Windows/DOS-FS incompatible chars when storing
78 # StupidFs: 0
79
80 # Experimental feature for apt-listbugs: pass-through SOAP requests and
81 # responses to/from bugs.debian.org. If not set, default is true if
82 # ForceManaged is enabled and false otherwise.
83 # ForwardBtsSoap: 1
84
85 # The daemon has a small cache for DNS data, to speed up resolution. The
86 # expiration time of the DNS entries can be configured in seconds.
87 # DnsCacheSeconds: 3600
88
89 # Don't touch the following values without good consideration!
90 #
91 # Max. count of connection threads kept ready (for faster response in the
92 # future). Should be a sane value between 0 and average number of connections,
93 # and depend on the amount of spare RAM.
94 # MaxStandbyConThreads: 8
95 #
96 # Hard limit of active thread count for incomming connections, i.e. operation
97 # is refused when this value is reached (below zero = unlimited).
98 # MaxConThreads: -1
99 #
100 #VfilePattern = (^|.*?/)(Index|Packages\.bz2|Packages\.gz|Packages|Release|Release\.gpg|Sources\.bz2|Sources\.gz|Sources|release|index\.db-.*\.gz|Contents-[^/]*\.gz|pkglist[^/]*\.bz2|rclist[^/]*\.bz2|/meta-release[^/]*|Translation[^/]*\.bz2)$
101 #PfilePattern = .*(\.deb|\.rpm|\.dsc|\.tar\.gz\.gpg|\.tar\.gz|\.diff\.gz|\.diff\.bz2|\.jigdo|\.template|changelog|copyright|\.udeb|\.diff/.*\.gz|vmlinuz|initrd\.gz|ReleaseAnnouncement)$
102 # Whitelist for expiration, file types not to be removed even when being
103 # unreferenced. Default: same as VfilePattern which is a safe bed. When and
104 # only when the only used mirrors are official repositories (with working
105 # Release files) then it might be set to something more restrictive, like
106 # (^|.*?/)(Release|Release\.gpg|release|meta-release|Translation[^/]*\.bz2)$
107 #WfilePattern = (^|.*?/)(Index|Packages\.bz2|Packages\.gz|Packages|Release|Release\.gpg|Sources\.bz2|Sources\.gz|Sources|release|index\.db-.*\.gz|Contents-[^/]*\.gz|pkglist[^/]*\.bz2|rclist[^/]*\.bz2|/meta-release[^/]*|Translation[^/]*\.bz2)$
108
109 # Higher modes only working with the debug version
110 # Warning, writes a lot into apt-cacher.err logfile
111 # Value overwrites UnbufferLogs setting (aliased)
112 Debug:2
113
114 # Usually, general purpose proxies like Squid expose the IP adress of the
115 # client user to the remote server using the X-Forwarded-For HTTP header. This
116 # behaviour can be optionally turned on with the Expose-Origin option.
117 # ExposeOrigin: 0
118
119 # When logging the originating IP address, trust the information supplied by
120 # the client in the X-Forwarded-For header.
121 # LogSubmittedOrigin: 0
122
123 # The version string reported to the peer, to be displayed as HTTP client (and
124 # version) in the logs of the mirror.
125 # WARNING: some archives use this header to detect/guess capabilities of the
126 # client (i.e. redirection support) and change the behaviour accordingly, while
127 # ACNG might not support the expected features. Expect side effects.
128 #
129 # UserAgent: Yet Another HTTP Client/1.2.3p4
130
131 # In some cases the Import and Expiration tasks might create fresh volatile
132 # data for internal use by reconstructing them using patch files. This
133 # by-product might be recompressed with bzip2 and with some luck the resulting
134 # file becomes identical to the *.bz2 file on the server, usable for APT
135 # clients trying to fetch the full .bz2 compressed version. Injection of the
136 # generated files into the cache has however a disadvantage on underpowered
137 # servers: bzip2 compession can create high load on the server system and the
138 # visible download of the busy .bz2 files also becomes slower.
139 #
140 # RecompBz2: 0
141
142 # Network timeout for outgoing connections.
143 # NetworkTimeout: 60
144
Generate a list of files for precaching
1 apt-get --print-uris update \
2 |cut -d\ -f1 \
3 |grep -e '/debian-security/' -e '/debian/dists/' \
4 |grep -e '/binary-amd64/' -e '/binary-all/' -e '/source/' \
5 |grep -e '/Sources' -e '/Packages' \
6 |sed -r -e "s/'//g" -e 's#^https?://[^/]+/(.*)$#\debrep/\1#' \
7 |sed -r -e 's/(main|contrib|non-free)/*/' -e 's/.(xz|gz)$/*/' \
8 |sort -u
9 ### FORMATED WITH YAML IDENTATION
10 apt-get --print-uris update \
11 |cut -d\ -f1 \
12 |grep -e '/debian-security/' -e '/debian/dists/' \
13 |grep -e '/binary-amd64/' -e '/binary-all/' -e '/source/' \
14 |grep -e '/Sources' -e '/Packages' \
15 |sed -r -e "s/'//g" -e 's#^https?://[^/]+/(.*)$#\debrep/\1#' \
16 |sed -r -e 's/(main|contrib|non-free)/*/' -e 's/.(xz|gz)$/*/' \
17 |sort -u \
18 |sed -e "s/^/ - '/" -e "s/$/'/"
Client
Manual configuration
/etc/apt/apt.conf.d/50proxy
auto-apt-proxy
automatic detector of common APT proxy settings
auto-apt-proxy installs itself as an APT proxy autodetector, and detects common setups by checking some hosts on the local network for well-known APT proxies such as apt-cacher-ng.
This package is most useful for development environments, and will Do The Right Thing for at least these cases:
- Build chroots, with a proxy running on the host system.
- Docker/lxc containers, with a proxy running on the host system.
- Virtual machines with NAT networking, with a proxy running on the host system.
- Any other system, with a proxy running on its default gateway.
Systems where the apt-proxy hostname resolves to a valid IP address and a supported proxy is detected at that address.
The following APT proxy servers are supported and automatically detected:
- apt-cacher-ng
- approx
- apt-cacher
- squid-deb-proxy
- any proxy advertised by an _apt_proxy._tcp SRV record in your domain
This package has a minimal set of dependencies in order to minimize the influence on systems where it is installed.
This package does not query mDNS SRV records, which would require avahi. If you need that, consider the squid-deb-proxy-client package instead.
Homepage: https://salsa.debian.org/debian/auto-apt-proxy
Install auto-apt-proxy
1 aptitude install auto-apt-proxy
It installs itself into
/etc/apt/apt.conf.d/auto-apt-proxy.conf
apt-config dump |grep -i proxy
1 Acquire::http::Proxy-Auto-Detect "/usr/bin/auto-apt-proxy";
On invocation it just returns either the proxy URL or DIRECT to signal that no proxy has been deteted.
/usr/bin/auto-apt-proxy
1 http://127.0.0.1:3142