The APT Cache Proxy Configurator is a tool designed to help users configure their Debian/Ubuntu systems (including Proxmox hosts, LXC containers, and VMs) to utilize an APT-Cacher-NG proxy server. This setup aims to enhance package download speeds and minimize bandwidth usage.
- APT Cache Proxy Configurator - User Guide
You have two options for installing the APT Cache Proxy Configurator:
Run this one-liner for a guided setup:
curl -fsSL https://raw.githubusercontent.com/GrandDay/apt-cache-config/main/install-interactive.sh | bashThe interactive installer will:
- Prompt you for your APT-Cacher-NG server IP and port
- Ask for your SSH configuration preferences
- Optionally accept an existing SSH public key
- Download and configure the script automatically
- Confirm all settings before installation
Example Session:
==========================================
APT Cache Proxy Configurator - Installer
==========================================
Enter APT-Cacher-NG server IP (default: 10.1.50.183): 192.168.1.100
Enter APT-Cacher-NG server port (default: 3142): 3142
Enter SSH user for VM access (default: root): root
Enter SSH key path (default: $HOME/.ssh/id_rsa): /root/.ssh/id_rsa
Do you have an existing SSH public key to use? (y/n): n
Configuration:
APT Proxy: http://192.168.1.100:3142
SSH User: root
SSH Key: /root/.ssh/id_rsa
Custom SSH Key: None (will generate if needed)
Proceed with installation? (y/n): y
If you prefer to configure manually:
# 1. Download the script
curl -o /usr/local/bin/connect-to-apt-cache.sh https://raw.githubusercontent.com/GrandDay/apt-cache-config/main/src/connect-to-apt-cache.sh
chmod +x /usr/local/bin/connect-to-apt-cache.sh
# 2. Edit configuration
nano /usr/local/bin/connect-to-apt-cache.sh
# 3. Verify installation
connect-to-apt-cache.shBefore running the script, you need to customize the configuration variables at the top of the script. Open the script in a text editor and modify the following variables:
APT_PROXY_SERVER="http://YOUR_SERVER_IP:3142" # Your apt-cacher-ng server address
SSH_USER="root" # SSH user for VM access
SSH_KEY_PATH="$HOME/.ssh/id_rsa" # Path to SSH private key
SSH_PUBLIC_KEY_PATH="$HOME/.ssh/id_rsa.pub" # Path to SSH public key
CUSTOM_SSH_PUBLIC_KEY="" # Optional: Paste existing SSH public keyThe script provides several commands to configure the APT proxy for different environments:
-
Configure Local System:
connect-to-apt-cache.sh local -
Configure a Single LXC Container:
connect-to-apt-cache.sh lxc-single <CTID>
-
Configure All LXC Containers:
connect-to-apt-cache.sh lxc-all
-
Configure a VM via SSH:
connect-to-apt-cache.sh vm <IP_ADDRESS> [username]
-
Remove APT Proxy Configuration:
connect-to-apt-cache.sh remove <type> <target>
-
Configure the local system:
connect-to-apt-cache.sh local -
Configure a specific LXC container:
connect-to-apt-cache.sh lxc-single 100
-
Configure a VM:
connect-to-apt-cache.sh vm 10.1.50.10
Error: Invalid proxy server format: <your-input>
Solution: Ensure your proxy URL matches the format http://IP:PORT (e.g., http://10.1.50.183:3142)
Error: Invalid IP address format: <your-input>
Solution: IP addresses must be in dotted decimal notation (e.g., 192.168.1.100)
Error: APT update failed - proxy may not be reachable
Troubleshooting Steps:
-
Test proxy connectivity:
curl -I http://YOUR_PROXY_IP:3142 # Should return HTTP 200 or 406 -
Verify apt-cacher-ng is running:
# On the cache server systemctl status apt-cacher-ng -
Check firewall rules:
# Ensure port 3142 is open sudo ufw status | grep 3142
-
Test manual package download:
# From the client system http_proxy="http://YOUR_PROXY_IP:3142" apt-get update
Error: Packages from HTTPS sources fail to download
Solution: Configure apt-cacher-ng to pass through HTTPS traffic:
On your apt-cacher-ng server, edit /etc/apt-cacher-ng/acng.conf:
# Add these lines (or uncomment if present)
PassThroughPattern: .*Then restart apt-cacher-ng:
sudo systemctl restart apt-cacher-ngError: Cannot establish SSH connection to <target>
Troubleshooting Steps:
-
Test SSH manually:
ssh -i ~/.ssh/id_rsa root@TARGET_IP -
Verify SSH key permissions:
chmod 600 ~/.ssh/id_rsa chmod 644 ~/.ssh/id_rsa.pub
-
Check SSH service on target:
# On the target system systemctl status sshd -
Re-run key copy:
ssh-copy-id -i ~/.ssh/id_rsa.pub root@TARGET_IP
Error: Container <CTID> does not exist or Container <CTID> is not running
Solution:
-
Verify container status:
pct list pct status <CTID>
-
Start the container if stopped:
pct start <CTID>
The script creates a single configuration file:
- Path:
/etc/apt/apt.conf.d/00aptproxy - Content:
Acquire::http::Proxy "http://YOUR_PROXY:3142";
To verify configuration:
# On configured system
cat /etc/apt/apt.conf.d/00aptproxy
apt-config dump | grep ProxyTo manually remove:
sudo rm /etc/apt/apt.conf.d/00aptproxyIf you continue experiencing issues:
- Check script output: The script provides color-coded feedback for each operation
- Review logs: Use
--verboseor check system logs for detailed error messages - Report issues: Visit https://github.com/GrandDay/apt-cache-config/issues
- Contact: Open an issue on GitHub with:
- Your configuration (redact IPs if sensitive)
- Full error output
- Output of
apt-config dump | grep Proxy
This project is licensed under the MIT License. See the LICENSE file for more details.