Skip to content

Commit fe49607

Browse files
committed
cleaning up APT cach
1 parent d620a9a commit fe49607

File tree

1 file changed

+50
-25
lines changed

1 file changed

+50
-25
lines changed

_posts/2025-03-17-APT-Cacher-NG.md

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,40 @@ APT-Cacher-NG is designed to cache Ubuntu, Debian, and other Linux distributions
3838

3939

4040
## HOW TO DO IT
41-
- ### **Phase 1**
42-
1. I have proxmox. I like Proxmox. I like LXC's. I like "easy." Paste this script into your **main PVE console.**\
43-
(*There is an `apt-get install` out there if you want to make an Ubuntu or Debian VM as well.*) I wil be using the Proxmox LXC becasue it is lightweight and easy.
44-
```
45-
bash -c "$(wget -qLO - https://github.com/community-scripts/ProxmoxVE/raw/main/ct/apt-cacher-ng.sh)"
46-
```
47-
- If you have not heard of Proxmox Helper Scripts, you should look around at them a bit more when you’re done with this! (*A lot of these were created by—and used to be run by **tteck**, if that rings a bell.*)\
48-
[Proxmox Helper Scripts - APT Cacher NG](https://community-scripts.github.io/ProxmoxVE/scripts?id=apt-cacher-ng)
49-
:-)
50-
Can't get easier than **Copy Pasta**, right? Follow the prompts.
5141

42+
- ### **Phase 1**
5243

53-
2. When that install finishes, you will get something like this.
54-
```
44+
**A.** I have proxmox. I like Proxmox. I like LXC's. I like "easy." Paste this script into your **main PVE console.**
45+
(*There is an `apt-get install` out there if you want to make an Ubuntu or Debian VM as well.*) I will be using the Proxmox LXC because it is lightweight and easy.
46+
47+
**B.** If you have not heard of Proxmox Helper Scripts, you should look around at them a bit more when you’re done with this!
48+
(*A lot of these were created by—and used to be run by **tteck**, if that rings a bell.*)
49+
50+
```bash
51+
bash -c "$(wget -qLO - https://github.com/community-scripts/ProxmoxVE/raw/main/ct/apt-cacher-ng.sh)"
52+
```
53+
54+
- [Proxmox Helper Scripts - APT Cacher NG](https://community-scripts.github.io/ProxmoxVE/scripts?id=apt-cacher-ng)
5555

56-
🚀 Apt-Cacher-NG setup has been successfully initialized!
57-
💡 Access it using the following URL:
58-
🌐 http://192.168.1.215:3142/acng-report.html
5956

60-
```
6157

62-
- Click the link, or type/paste it in a web browser. This is the APT Cache GUI. You won't have anything there yet—so just save it, bookmark it, or note it for later.
63-
- Also, make sure you have set up a DHCP reservation or a static IP, so the IP doesn't change on you.
58+
- Can't get easier than **Copy Pasta**, right? Follow the prompts.
59+
60+
- When that install finishes, you will get something like this.
61+
62+
> 🚀 Apt-Cacher-NG setup has been successfully initialized!
63+
> 💡 Access it using the following URL:
64+
> 🌐 http://192.168.1.215:3142/acng-report.html
65+
66+
**C.** Click the link, or type/paste it in a web browser. This is the APT Cache GUI. You won't have anything there yet—so just save it, bookmark it, or note it for later.
67+
68+
**D.** Also, make sure you have set up a DHCP reservation or a static IP, so the IP doesn't change on you.
69+
6470

6571

6672
#### THE SERVER IS SET!
6773

68-
3. I told you that was easy. The final step of **Phase 1** is to update the client. Here is the easy way, and then I’ll explain.
74+
**E.** I told you that was easy. The final step of **Phase 1** is to update the client. Here is the easy way, and then I’ll explain.
6975
This is the command—paste it on the CLIENT (do a VM or another Linux box; LXCs are a tad different). Replace the IP below with your Server IP.
7076
- This command tells the Ubuntu VM instance to look to the Server when it runs an update.
7177

@@ -81,7 +87,7 @@ echo 'Acquire::http::Proxy "http://192.168.1.215:3142";' | sudo tee /etc/apt/apt
8187

8288

8389

84-
4. **NOTES** on what we did, and more on Phase 1.
90+
**F.** **NOTES** on what we did, and more on Phase 1.
8591
- Located in **`/etc/apt-cacher-ng/acng.conf`**\
8692
The default config in the LXC Server is `PassThroughPattern: .*`\
8793

@@ -121,7 +127,8 @@ sudo sed -i 's#http://HTTPS///#https://#g' /etc/apt/sources.list.d/docker.list
121127

122128

123129
- ### **Phase 2**: Cache some repositories
124-
1. This phase takes up a little space—not much, really. We are going to list repositories to cache and then hit the GUI button to cache them.
130+
131+
**A.** This phase takes up a little space—not much, really. We are going to list repositories to cache and then hit the GUI button to cache them.
125132
Here are the two things you need (replace your IP's here):
126133
- GUI: http://192.168.1.215:3142/acng-report.html
127134
- CONFIG on the SERVER: **`/etc/apt-cacher-ng/acng.conf`**
@@ -169,7 +176,7 @@ PrecacheFor: debrep/pool/main/r/redis
169176
Remap-proxmox: debrep/dists/pve/*/binary-amd64/Packages* ; http://download.proxmox.com/debian/pve
170177
PrecacheFor: debrep/dists/pve/*/binary-amd64/Packages*
171178
```
172-
2. On the GUI
179+
**B.**On the GUI
173180
![guided precaching](Images/APT-Cache-NG/guided_precaching.png)
174181

175182

@@ -179,18 +186,24 @@ PrecacheFor: debrep/dists/pve/*/binary-amd64/Packages*
179186

180187
- That wasn't bad, right? Done with **Phase 2**
181188

182-
- I will add this note here. At one point, I added this command to the `acng.conf.` I don't recall if it is still needed. I think I needed it when I was messing around with Phase 3. `AllowUserPorts: 80 443`
183189

184190
**Phase 3**
185191
- Full disclosure, I quit bothering with this. The trouble of trying to update, and getting an error, and then diving back into `acng.conf` file and adding something, then trying an update again, was more of a pain than I wanted to deal with. Perhaps, you have better luck. Ideally, if you resolve every error, by adding to this, then everything will be great. But just as I thought I had it figured out, I got another error, and said "To heck with it."
186192

187193
- The default is: `PassThroughPattern: .*` and that lets everything through.
194+
188195
- I suggest `PassThroughPattern: ^(.*):443$` since that lets all HTTPS through.
196+
189197
- If you want to get granular and make sure nothing gets through that shouldn’t, uncomment the above and add something like this:\
190-
`PrecacheFor: debrep/dists/unstable/*/source/Sources* debrep/dists/unstable/*/binary-amd64/Packages*`\
198+
`PassThroughPattern: (packagecloud\.io|packagecloud-repositories\.s3\.dualstack\.us-west-1\.amazonaws\.com|packagecloud-prod\.global\.ssl\.fastly\.net):443$`
199+
200+
`PassThroughPattern: ^(bugs\.debian\.org|changelogs\.ubuntu\.com):443$`
201+
191202
- Adjust as needed.
203+
192204
- I got to this point and gave up:\
193-
`PassThroughPattern: ^(changelogs\.ubuntu\.com|download\.docker\.com|developer\.download\.nvidia\.com|apt\.grafana\.com|repos\.influxdata\.com|ppa\.launchpad\.net|p>`\
205+
`PassThroughPattern: ^(changelogs\.ubuntu\.com|download\.docker\.com|developer\.download\.nvidia\.com|apt\.grafana\.com|repos\.influxdata\.com|ppa\.launchpad\.net|p>`\ (maybe I was doing it wrong?)
206+
194207
Reverting back to:\
195208
`PassThroughPattern: ^(.*):443$`
196209

@@ -206,6 +219,18 @@ PrecacheFor: debrep/dists/pve/*/binary-amd64/Packages*
206219

207220

208221

222+
# Additional commands
223+
224+
- for a "do release upgrade" - `sudo HTTP_PROXY="http://192.168.1.125:3142" do-release-upgrade`
225+
226+
- or bypass the proxy `sudo HTTP_PROXY="" do-release-upgrade`
227+
228+
- Follow the Logs in a LXC - `tail -f /var/log/apt-cacher-ng/apt-cacher.log | pv -q -L 1k`
229+
230+
- Removes it from an LXC - `rm /etc/apt/apt.conf.d/00aptproxy` - in the LXC console.
231+
232+
233+
209234

210235

211236
# Sources

0 commit comments

Comments
 (0)