{"id":18267146,"url":"https://github.com/skrik2/iacs","last_synced_at":"2026-02-02T10:33:14.233Z","repository":{"id":258472033,"uuid":"873719745","full_name":"skrik2/iacs","owner":"skrik2","description":"Intranet Apt Cache Server","archived":false,"fork":false,"pushed_at":"2024-12-07T18:14:33.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-20T05:57:35.319Z","etag":null,"topics":["apt","apt-get","cache-server","mirror"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skrik2.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-16T15:50:35.000Z","updated_at":"2024-12-07T18:14:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"9a6a2428-5b64-4f6d-a262-9aeb8ad5fb4f","html_url":"https://github.com/skrik2/iacs","commit_stats":null,"previous_names":["nealhallyoung/iacs","yanghao5/iacs","skrik2/iacs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/skrik2/iacs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skrik2%2Fiacs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skrik2%2Fiacs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skrik2%2Fiacs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skrik2%2Fiacs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skrik2","download_url":"https://codeload.github.com/skrik2/iacs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skrik2%2Fiacs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281715311,"owners_count":26549145,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-29T02:00:06.901Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apt","apt-get","cache-server","mirror"],"created_at":"2024-11-05T11:26:11.601Z","updated_at":"2025-10-29T23:30:59.707Z","avatar_url":"https://github.com/skrik2.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# 内网搭建 apt 缓存镜像服务器\n\n当你需要频繁地使用 apt 安装软件时，无论你的网多好，都很“慢”。\n\n在内网搭建一个缓存服务器，就非常非常快了。\n\n毕竟，外网的网速是以 MB 计算，而内网的网速是以 GB 计算。\n\n\n\n总体思路：用 apt-cacher-ng 搭建 apt 缓存服务器；通过修改客户端的 sources.list 使用缓存服务器\n\n操作系统版本：debian 12.7\n\n\n\n\u003e NB\n\u003e\n\u003e apt-cacher-ng 只缓存请求的文件，你没请求的，它不会缓存。\n\u003e\n\u003e 如果你想要搭建一个完整的 apt 镜像站。\n\u003e\n\u003e 你可以使用 apt-mirror\n\u003e\n\u003e https://github.com/apt-mirror/apt-mirror\n\n# 缓存服务器搭建\n\n## 安装 apt-cacher-ng\n\n```\nsudo apt-get update \u0026\u0026 sudo apt-get install apt-cacher-ng -y\n```\n\n## 修改配置文件\n\n我使用的配置文件，放在了这个仓库里。\n\nhttps://github.com/nealhallyoung/iacs.git\n\n你可以在此基础上修改配置，或者不改直接用。\n\n```\n# 先备份原始配置文件\nsudo mv /etc/apt-cacher-ng/acng.conf ~/acng.conf.bk\n# 下载配置文件\ngit clone --depth=1 https://github.com/nealhallyoung/iacs.git \u0026\u0026 cd iacs\n# 移动配置文件\n# 你也可以做一些修改，我会给出一些关键点\n# mv acng.conf /etc/apt-cacher-ng/acng.conf\n```\n\n### 关键点\n\n```\n# 缓存文件夹地址，你想把缓存文件存储到什么地方\nCacheDir: /var/cache/apt-cacher-ng\n\n# 服务端口\nPort:3142\n\n# 设置缓存文件过期时间，单位 天。默认为 4 天\n# 我设置成了 30 天过期，你要根据自己的安全需求来改\nExThreshold: 30\n\n# The number can have a suffix (k,K,m,M for Kb,KiB,Mb,MiB)\n# 缓存多少文件时，会清理过期文件\n# 我设置成 10GiB \nExStartTradeOff: 10240M\n```\n\n### 更高级的用法\n\napt-cacher-ng 有很多其他功能\n\n文档\n\nhttps://www.unix-ag.uni-kl.de/~bloch/acng/\n\n你可以去阅读相关内容\n\n## 启动服务器\n\n```\nsudo systemctl enable apt-cacher-ng\nsudo systemctl restart apt-cacher-ng\n# 查看状态\nsystemctl status apt-cacher-ng\n# 查看日志\njournalctl -u apt-cacher-ng\n```\n\n打开浏览器访问 http://ip:port\n\n比如我的是 http://192.168.40.133:3142\n\n你会看到管理界面\n\n# 客户端使用\n\n## 修改 sources.list\n\n\u003e NB\n\u003e\n\u003e 2024 年应该用的都是 https 的镜像站点吧！！！\n\u003e\n\u003e 如果，你用的是 http 站点，你可以参考官方文档做一点点修改就可以用。\n\n在这里是关于 https 镜像站的使用。\n\n官方文档 https://www.unix-ag.uni-kl.de/~bloch/acng/html/howtos.html#ssluse\n\n假设\n\n1。你使用阿里云镜像 `https://mirrors.aliyun.com/debian/ `\n\n2。搭建的 apt-cacher-ng 缓存服务器地址 `http://192.168.40:3142` \n\n你需要把 `https://` 改成`http://192.168.40:3142/HTTPS///`\n\n原本是这样\n\n```\n# debian 12\ndeb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib\n# deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib\ndeb https://mirrors.aliyun.com/debian-security/ bookworm-security main\n# deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main\ndeb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib\n# deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib\ndeb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib\n# deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib\n```\n\n改成这样\n\n```\n# debian 12\ndeb deb http://192.168.40.133:3142/HTTPS///mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib\n# deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib\n\ndeb deb http://192.168.40.133:3142/HTTPS///mirrors.aliyun.com/debian-security/ bookworm-security main\n# deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main\n\ndeb deb http://192.168.40.133:3142/HTTPS///mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib\n# deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib\n\ndeb deb http://192.168.40.133:3142/HTTPS///mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib\n# deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib\n```\n\n\u003e NB\n\u003e\n\u003e 如果你除了 /etc/apt/sources.list 还有其他的 apt 源文件，你也可以相应地做修改\n\n## 清理 apt 缓存\n\n```\nsudo rm -rf /var/cache/apt/*  \u0026\u0026 sudo rm -rf /var/lib/apt/lists/*\nsudo apt-get clean\n```\n\n## 测试\n\n准备两台机器\n\n在 A 机器上先安装\n\n```\n# 这三个都是比较大的软件\nsudo apt install build-essential\nsudo apt install libreoffice\nsudo apt install wine\n```\n\n在 B 上再次安装\n\n如果没问题，下载速度，应该非常快。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskrik2%2Fiacs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskrik2%2Fiacs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskrik2%2Fiacs/lists"}