Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

[Ubuntu / Debian / CentOS / Alpine] Lightweight APT / YUM / APK CHACHE PROXY just over 2MB in size!

License

NotificationsYou must be signed in to change notification settings

soulteary/apt-proxy

 
 

Repository files navigation

Security ScanReleasegoreportcardDocker Image

ENGLISH |中文文档

A lightweightAPT Cache Proxy - just over 2MB in size!

APT Proxy is a lightweight and reliable caching tool forAPT, YUM, and APK packages (supporting Ubuntu, Debian, CentOS, and Alpine Linux). It's designed to work seamlessly with both traditional system installations and Docker environments.

It serves as a drop-in replacement forapt-cacher-ng.

Supported Platforms

  • Linux: x86_64 / x86_32 / Ubuntu ARM64v8
  • ARM: ARM64v8 / ARM32v6 / ARM32v7
  • macOS: x86_64 / Apple Silicon (ARM64v8)

Getting Started

Simply run the binary:

./apt-proxy2022/06/12 16:15:40 running apt-proxy2022/06/12 16:15:41 Start benchmarking mirrors2022/06/12 16:15:41 Finished benchmarking mirrors2022/06/12 16:15:41 using fastest mirror https://mirrors.company.ltd/ubuntu/2022/06/12 16:15:41 proxy listening on 0.0.0.0:3142

Ubuntu / Debian Support

To use the proxy withapt-get commands, prefix them with the proxy settings:

# Update package lists using apt-proxyhttp_proxy=http://your-domain-or-ip-address:3142 apt-get -o pkgProblemResolver=true -o Acquire::http=true update# Install packages using apt-proxyhttp_proxy=http://your-domain-or-ip-address:3142 apt-get -o pkgProblemResolver=true -o Acquire::http=true install vim -y

Subsequent package operations will be significantly faster as packages are cached locally.

CentOS Support

While CentOS uses Yum instead of APT, APT-Proxy provides acceleration for both CentOS 7 and 8.

For CentOS 7:

cat /etc/yum.repos.d/CentOS-Base.repo| sed -e s/mirrorlist.*$//| sed -e s/#baseurl/baseurl/ | sed -e s#http://mirror.centos.org#http://your-domain-or-ip-address:3142# | tee /etc/yum.repos.d/CentOS-Base.repo

For CentOS 8:

sed -i -e"s#mirror.centos.org#http://your-domain-or-ip-address:3142#g" /etc/yum.repos.d/CentOS-*sed -i -e"s/#baseurl/baseurl/" /etc/yum.repos.d/CentOS-*sed -i -e"s#\$releasever/#8-stream/#" /etc/yum.repos.d/CentOS-*

Verify the configuration by runningyum update.

Alpine Linux Support

APT Proxy also accelerates package downloads for Alpine Linux:

cat /etc/apk/repositories| sed -e s#https://.*.alpinelinux.org#http://your-domain-or-ip-address:3142#| tee /etc/apk/repositories

Verify the configuration by runningapk update.

Mirror Configuration

You can specify mirrors in two ways:

Using Full URLs:

# Cache both Ubuntu and Debian packages./apt-proxy --ubuntu=https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ --debian=https://mirrors.tuna.tsinghua.edu.cn/debian/# Cache Ubuntu packages only./apt-proxy --mode=ubuntu --ubuntu=https://mirrors.tuna.tsinghua.edu.cn/ubuntu/# Cache Debian packages only./apt-proxy --mode=debian --debian=https://mirrors.tuna.tsinghua.edu.cn/debian/

Using Shortcuts:

go run apt-proxy.go --ubuntu=cn:tsinghua --debian=cn:1632022/06/15 10:55:26 running apt-proxy2022/06/15 10:55:26 using specify debian mirror https://mirrors.163.com/debian/2022/06/15 10:55:26 using specify ubuntu mirror https://mirrors.tuna.tsinghua.edu.cn/ubuntu/2022/06/15 10:55:26 proxy listening on 0.0.0.0:3142

Available shortcuts:

  • cn:tsinghua
  • cn:ustc
  • cn:163
  • cn:aliyun
  • cn:huaweicloud
  • cn:tencent and more...

Docker Integration

To accelerate package installation in Docker containers:

# Start a container (Ubuntu or Debian)docker run --rm -it ubuntu# ordocker run --rm -it debian# Install packages using the proxyhttp_proxy=http://host.docker.internal:3142 apt-get -o Debug::pkgProblemResolver=true -o Debug::Acquire::http=true update&& \http_proxy=http://host.docker.internal:3142 apt-get -o Debug::pkgProblemResolver=true -o Debug::Acquire::http=true install vim -y

Docker Deployment

Deploy with a single command:

docker run -d --name=apt-proxy -p 3142:3142 soulteary/apt-proxy

Configuration Options

./apt-proxy -hUsage of apt-proxy:  -alpine string    the alpine mirrorfor fetching packages  -cachedir string    the dir to store cache datain (default"./.aptcache")  -centos string    the centos mirrorfor fetching packages  -debian string    the debian mirrorfor fetching packages  -debug    whether to output debugging logging  -host string    the host tobind to (default"0.0.0.0")  -mode allselectthe mode of system to cache: all /`ubuntu` /`debian` /`centos` /`alpine` (default"all")  -port string    the port tobind to (default"3142")  -ubuntu string    the ubuntu mirrorfor fetching packages

Development

Running Tests:

# Run tests with coverage reportinggotest -cover ./...# Generate and view detailed coverage reportgotest -coverprofile=coverage.out ./...go tool cover -html=coverage.out

Debugging Package Operations

For Ubuntu/Debian:

http_proxy=http://192.168.33.1:3142 apt-get -o Debug::pkgProblemResolver=true -o Debug::Acquire::http=true updatehttp_proxy=http://192.168.33.1:3142 apt-get -o Debug::pkgProblemResolver=true -o Debug::Acquire::http=true install apache2

License

This project is licensed under theApache License 2.0.

Dependencies


[8]ページ先頭

©2009-2025 Movatter.jp