镜像资源站

img

一. 前言

# Windows预置的时间同步服务器, time.windows.com, 就属于可访问, 但速度慢不稳地
ntp.ntsc.ac.cn   # 中国国家授时中心

由于大清特殊的国情和外部的某些原因, 不少境外站点的访问很多时候都是问题. 不是无法访问就是速度如蜗牛, 亦或者135墙, 246放, 间歇性的可访问.

尽管有梯子存在, 但是在下载大文件, 代理的设置方面都存在各种问题, 镜像资源站的存在就很重要了.

以下为一些镜像站和js的静态资源站以及基本的配置.

二. 企业站

企业站可能速度没问题, 但是在使用上总不是很顺手, 如, 使用华为的源, 在安装TensorFlow时报错, 但是换成清华源就没问题.

镜像站 地址 备注
阿里云镜像站 https://developer.aliyun.com/mirror -
华为云镜像 https://mirrors.huaweicloud.com 1Gbps
腾讯软件源 https://mirrors.tencent.com -
火山引擎镜像站 https://developer.volcengine.com/mirror/ -
天翼云开源镜像站 http://mirrors.ctyun.cn -

三. 国内大学镜像站

高校站最大的问题是服务的稳定性和速度, 毕竟相关服务除了技术之外, 硬件的投入也是颇大.

[中国高校教育网及科技网开源镜像列表 China GNU/Linux User Group]

img

在一众理工科大学中, 有个相对独特的存在: 山东女子学院镜像站, 可惜网站下线了.

镜像站 地址 备注
清华大学开源软件镜像站 https://mirrors.tuna.tsinghua.edu.cn 20Gbps
浙江大学开源软件镜像站 https://mirrors.zju.edu.cn -
中国科学技术大学开源软件镜像 https://mirrors.ustc.edu.cn -
上海交大致远镜像站 https://mirrors.sjtug.sjtu.edu.cn -
南京大学开源镜像站 https://mirror.nju.edu.cn -
北京外国语大学开源软件镜像站 https://mirrors.bfsu.edu.cn 2Gbps,tunasync
山东大学镜像站 https://mirrors.sdu.edu.cn -
齐鲁工业大学开源软件镜像站 https://mirrors.qlu.edu.cn 10Gbps,tunasync
南阳理工学院开源软件镜像站 https://mirror.nyist.edu.cn 10Gbps,tunasync
南方科技大学开源软件镜像站 https://mirrors.sustech.edu.cn tunasync
北京交通大学自由与开源软件镜像站 https://mirror.bjtu.edu.cn -
西安交通大学软件镜像站 https://mirrors.xjtu.edu.cn -
吉林大学开源镜像站 https://mirrors.jlu.edu.cn -
兰州大学开源社区镜像站 https://mirror.lzu.edu.cn -
哈尔滨工业大学开源镜像站 https://mirrors.hit.edu.cn -
ISCAS 镜像站 https://mirror.iscas.ac.cn -
南京工业大学开源软件镜像站 https://mirrors.njtech.edu.cn -
西北农业大学 https://mirrors.nwafu.edu.cn -
北京大学开源镜像站 https://mirrors.pku.edu.cn -
华中科技大学开源镜像站 https://mirrors.hust.edu.cn tunasync
上海交通大学FTP https://ftp.sjtu.edu.cn/html/index.xml -
交大資工系計算機中心 https://linux.cs.nctu.edu.tw 1Gbps
國研院國網中心自由軟體實驗室 https://free.nchc.org.tw/pmwiki 1Gbps
Taiwan Digital Streaming https://mirror.twds.com.tw 80Gbps,tunasync
北京交通大学 http://mirror.bjtu.edu.cn/cn -
中山大学开源软件镜像站 http://mirror.sysu.edu.cn 试运行,tunasync
西北农林科技大学 https://mirrors.nwsuaf.edu.cn tunasync

(国内软件源镜像站一览表(2025年状态更新) - 知乎

3.1 清华镜像源

清华源是相对特殊的, 在一众高校镜像源中, 清华大学这个站, 上线时间相对较早, 资源丰富, 近些年来服务的稳定性得到保障, 以及帮助手册对新手很好, 应该是国内用户量最大的镜像站点.

例如, pip的某些包在官方原站点没有, 但是清华站却依然可以下载到.

除此之外, 清华大学 TUNA 协会 还有其他更多的服务支持, Oh My TUNA, 提供了一个集成脚本修改相关设置.

模块 适用场景 核心操作
Pypi Python 的 pip 工具 修改 pip.conf 配置文件, 设置索引 URL 为清华 PyPI 镜像.
ArchLinux Arch Linux 系统 修改 /etc/pacman.d/mirrorlist, 添加清华 Arch 镜像源.
Homebrew macOS 的 Homebrew 包管理 修改 brew 仓库远程地址, 设置 HOMEBREW_BOTTLE_DOMAIN 环境变量.
CTAN TeX Live 的 tlmgr 工具 通过 tlmgr 命令切换 CTAN 镜像源为清华镜像.
Anaconda Anaconda/Miniconda 通过 conda config 添加清华 Anaconda 镜像通道.
Debian Debian 系统 替换 /etc/apt/sources.list 为清华 Debian 镜像源( 备份原文件) .
Ubuntu Ubuntu 系统 类似 Debian, 替换 sources.list 为清华 Ubuntu 镜像源( 含 ports 支持) .
CentOS CentOS 系统 修改 /etc/yum.repos.d/CentOS-Base.repo, 替换为清华 CentOS 镜像.
AOSCOS AOSC OS 系统 通过 apt-gen-list 命令添加清华 AOSC 镜像源.

清华大学开源软件镜像站 | Tsinghua Open Source Mirror

3.2 小结

集合版本: 校园网联合镜像站

四. 修改源

使用清华源全家桶, 中科大和阿里作为备份.

4.1 pip

# 单独使用
pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple some-package_name

# 全局设置
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple

# 备用中科大: https://mirrors.ustc.edu.cn/pypi/web/simple

pypi | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

4.2 conda

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

备用中科大: Anaconda - USTC Mirror Help

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/r
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.ustc.edu.cn/anaconda/cloud
  bioconda: https://mirrors.ustc.edu.cn/anaconda/cloud

anaconda | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

4.3 npm

npm config set registry https://mirrors.tuna.tsinghua.edu.cn/npm/

npm config get registry # 查看
npm config set registry https://registry.npmjs.org # 恢复默认

npm config set registry https://registry.npmmirror.com # 备用淘宝

nodejs-release | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

4.4 ubuntu

新的路径:

sudo vi /etc/apt/sources.list.d/ubuntu.sources

ubuntu24修改了源文件的位置: /etc/apt/sources.list

Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# 默认注释了源码镜像以提高 apt update 速度, 如有需要可自行取消注释
# Types: deb-src
# URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
# Suites: noble noble-updates noble-backports
# Components: main restricted universe multiverse
# Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# 以下安全更新软件源包含了官方源与镜像站配置, 如有需要可自行修改注释切换
Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# Types: deb-src
# URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
# Suites: noble-security
# Components: main restricted universe multiverse
# Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# 预发布软件源, 不建议启用

# Types: deb
# URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
# Suites: noble-proposed
# Components: main restricted universe multiverse
# Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# # Types: deb-src
# # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
# # Suites: noble-proposed
# # Components: main restricted universe multiverse
# # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

ubuntu | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

4.5 docker

docker 镜像源不知道是因为商业缘故(docker公司对拉取镜像进行收费)还是清廷的干预, 并没有规模组织开设相关的镜像站点.

管理工具, 这里使用的是podman.io, 不是用原版docker, 在使用上和docker一致.

安装

# Ubuntu 20.10 and newer
sudo apt-get update
sudo apt-get -y install podman

(base) lian@jarvis:~$ podman version
Client:       Podman Engine
Version:      4.9.3
API Version:  4.9.3
Go Version:   go1.22.2
Built:        Thu Jan  1 00:00:00 1970
OS/Arch:      linux/amd64

Podman 安装 | Podman 容器工具

拉取镜像, 只能是八仙过海各显神通.

一些常见的镜像: Microsoft Artifact Registry

需要重点关注的是GitHub出品: Introducing GitHub Container Registry - The GitHub Blog

Github Container Registry

使用github action 构建镜像并上传到github registry在这篇文章中, 我将讨论 GHCR 是什么, - 掘金

sudo vi /etc/containers/registries.conf

# 配置 Podman 使用 Xget 镜像加速
# 编辑 /etc/containers/registries.conf
[[registry]]
prefix = "ghcr.io"
location = "xget.xi-xu.me/cr/ghcr"

# 或者直接拉取
podman pull xget.xi-xu.me/cr/ghcr/alpine/alpine:latest
podman pull xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
sudo systemctl restart podman

podman info | grep -A 10 "Registry Mirrors"

修改之后重启服务, 查看修改是否生效, 假如配置存在问题会报错.

Docker Hub 镜像加速服务

podman pull docker-0.unsee.tech/soulteary/flare

# 查看镜像文件
(base) lian@jarvis:~$ podman images
REPOSITORY                           TAG         IMAGE ID      CREATED        SIZE
ghcr.io/ajnart/homarr                latest      706a61f2e7a1  6 weeks ago    1.02 GB
docker-0.unsee.tech/soulteary/flare  latest      4b05693db111  17 months ago  14.8 MB

# 运行, 第一次运行
podman run -d --name flare -p 5005:5005 docker-0.unsee.tech/soulteary/flare # 这个项目只能使用5005端口, 否则无法正常运行

# 查看容器状态( 是否运行中)
podman ps | grep flare

# 查看容器
(base) lian@jarvis:~$ podman ps
CONTAINER ID  IMAGE                                       COMMAND     CREATED      STATUS        PORTS
     NAMES
20bce8d071c3  docker-0.unsee.tech/soulteary/flare:latest  flare       4 hours ago  Up 2 minutes  0.0.0.0:5005->5005/tcp  flare

# 查看容器的端口映射关系
podman port flare

# 重启容器
podman restart flare

# 启动容器, 下次启用不需要run
podman start flare

# 实时查看日志输出( 启动过程的详细信息)
podman logs -f flare

img

南京大学对相关内容做了比较清晰的整理, 容器缓存镜像添新丁了

渡渡鸟镜像同步站


命令 功能 示例
docker run 启动一个新的容器并运行命令 docker run -d ubuntu
docker ps 列出当前正在运行的容器 docker ps
docker ps -a 列出所有容器( 包括已停止的容器) docker ps -a
docker build 使用 Dockerfile 构建镜像 docker build -t my-image .
docker images 列出本地存储的所有镜像 docker images
docker pull 从 Docker 仓库拉取镜像 docker pull ubuntu
docker push 将镜像推送到 Docker 仓库 docker push my-image
docker exec 在运行的容器中执行命令 docker exec -it container_name bash
docker stop 停止一个或多个容器 docker stop container_name
docker start 启动已停止的容器 docker start container_name
docker restart 重启一个容器 docker restart container_name
docker rm 删除一个或多个容器 docker rm container_name
docker rmi 删除一个或多个镜像 docker rmi my-image
docker logs 查看容器的日志 docker logs container_name
docker inspect 获取容器或镜像的详细信息 docker inspect container_name
docker exec -it 进入容器的交互式终端 docker exec -it container_name /bin/bash
docker network ls 列出所有 Docker 网络 docker network ls
docker volume ls 列出所有 Docker 卷 docker volume ls
docker-compose up 启动多容器应用( 从 docker-compose.yml 文件) docker-compose up
docker-compose down 停止并删除由 docker-compose 启动的容器, 网络等 docker-compose down
docker info 显示 Docker 系统的详细信息 docker info
docker version 显示 Docker 客户端和守护进程的版本信息 docker version
docker stats 显示容器的实时资源使用情况 docker stats
docker login 登录 Docker 仓库 docker login
docker logout 登出 Docker 仓库 docker logout

常用选项说明:

  • -d: 后台运行容器, 例如 docker run -d ubuntu.
  • -it: 以交互式终端运行容器, 例如 docker exec -it container_name bash.
  • -t: 为镜像指定标签, 例如 docker build -t my-image ..

Docker 容器使用 | 菜鸟教程

五. JS静态资源库

在使用镜像站/资源站时, 各位是否会想一个问题, 镜像站会不会修改其保存的文件, 如常见的加入广告.

npm 软件包网站被滥用, 开发者上传超 700 个< 武林外传> 切片视频 - IT之家, npm的脆弱.

[XZ Utils( CVE-2024-3094) 供应链投毒深度分析 | 天融信阿尔法实验室](https://blog.topsec.com.cn/xz-utils( cve-2024-3094) -供应链投毒深度分析/), 软件供应链投毒在当下成为一种高效的计算机攻击方式, js静态资源也不能幸免成为受害者.

img

字节跳动静态资源公共库( 已下线)

国内各家曾经上线过一些带有一定公益属性的项目, 但是大多下架, 例如新浪, 百度, 360等均不在提供相关资源.

前端公共资源CDN存储库大全-持续更新

一些来路有点存疑的站点成为了很多人的选择, 特别自建小型站点时调用.

Bootcss CDN 疑似被投毒 - V2EX

【转载】继Bootcdn之后, Goedge被官方通过jQueryJS投毒 - 前沿快讯 - LINUX DO

但需要注意替换掉Bootcss CDN时需要检查在其他的站点是否也同样存在目标资源.

img

清廷很恶心, 对很多境外站点采用间歇式阻挡, 让站点可用也不可用, 如jsDelivr, 很多时候访问没问题, 但是换个时间段, 换个地点, 又不可访问. 导致一些项目会用这些站点的资源, 在用的时候不得不将这些资源替换掉.


7ED | Services

静态资源 Zstatic.net

JSDMirror镜像站-jsdelivr国内;jsdelivr镜像

以上得到较多推荐, 安全性据说有一定保证的, 同时速度也很快.

img

img

但需要注意上面有个站点, 但不知道搞什么, tampermonkey 一直无法加载脚本,换一个源就可以正常加载.

六. 总结

除上述的方式之外, 还有针对处理单一链接的, 支持docker.

xixu-me/Xget: 超高性能, 安全的一站式开发者资源访问加速引擎. 其性能远超传统加速器, 为您提供跨多个平台的统一高效的加速体验, 涵盖代码储存库, 包管理, AI 推理 API, 容器镜像, 模型及数据集等 | Ultra-high-performance, secure, all-in-one acceleration engine for developer resource access. Its performance far exceeds that of traditional accelerators, providing you with a unified and efficient acceleration experience across multiple platforms

import sys
import pyperclip as pc

def copy_data_to_clip(data_text: str):
    print("\n" + data_text + "\n")
    pc.copy(data_text)
    pc.paste()

def replace(url: str):
    data_list = [
        ('https://github.com/', 'gh',),
        ('https://gitlab.com/', 'gl',),
        ('https://gitea.com/', 'gitea',),
        ('https://codeberg.org/', 'codeberg',),
        ('https://sourceforge.net/', 'sf',),
        ('https://android.googlesource.com/', 'aosp',),
        ('https://huggingface.co/', 'hf',),
        ('https://civitai.com/', 'civitai',),
        ('https://registry.npmjs.org/', 'npm',),
        ('https://pypi.org/', 'pypi',),
        ('https://repo.anaconda.com/', 'conda',),
        ('https://repo1.maven.org/', 'maven',),
        ('https://downloads.apache.org/', 'apache',),
        ('https://plugins.gradle.org/', 'gradle',),
        ('https://github.com/Homebrew/', 'homebrew',),
        ('https://rubygems.org/', 'rubygems',),
        ('https://cran.r-project.org/', 'cran',),
        ('https://www.cpan.org/', 'cpan',),
        ('https://tug.ctan.org/', 'ctan',),
        ('https://proxy.golang.org/', 'golang',),
        ('https://api.nuget.org/', 'nuget',),
        ('https://crates.io/', 'crates',),
        ('https://repo.packagist.org/', 'packagist',),
        ('https://deb.debian.org/', 'debian',),
        ('https://archive.ubuntu.com/', 'ubuntu',),
        ('https://dl.fedoraproject.org/', 'fedora',),
        ('https://download.rockylinux.org/', 'rocky',),
        ('https://download.opensuse.org/', 'opensuse',),
        ('https://geo.mirror.pkgbuild.com/', 'arch',),
        ('https://arxiv.org/', 'arxiv',),
        ('https://f-droid.org/', 'fdroid',),
        ('https://updates.jenkins.io/', 'jenkins',)
    ]
    for pref, flag in data_list:
        if url.startswith(pref):
            new_url = f'https://xget.xi-xu.me/{flag}/{url[len(pref):]}'
            copy_data_to_clip(new_url)
            break

def main():
    if len(sys.argv) == 2:
        if url := sys.argv[1].strip():
            replace(url)

if __name__ == '__main__':
    main()

写了脚本方便在终端上转为url.