8000 GitHub - sundys/hubproxy: 基于Go的自托管轻量级、高性能的多功能代理加速服务,提供 Docker 镜像加速、GitHub 加速、下载离线镜像等功能。单域名实现所有功能,支持仓库审计。流式转发,无缓存。
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
forked from sky22333/hubproxy

基于Go的自托管轻量级、高性能的多功能代理加速服务,提供 Docker 镜像加速、GitHub 加速、下载离线镜像等功能。单域名实现所有功能,支持仓库审计。流式转发,无缓存。

License

Notifications You must be signed in to change notification settings

sundys/hubproxy

 
 

Repository files navigation

HubProxy

🚀 Docker 和 GitHub 加速代理服务器

一个轻量级、高性能的多功能代理服务,提供 Docker 镜像加速、GitHub 文件加速、下载离线镜像、在线搜索 Docker 镜像等功能。

Visitors

✨ 特性

  • 🐳 Docker 镜像加速 - 单域名实现 Docker Hub、GHCR、Quay 等多个镜像仓库加速,流式传输优化拉取速度。
  • 🐳 离线镜像包 - 支持下载离线镜像包,流式传输加防抖设计。
  • 📁 GitHub 文件加速 - 加速 GitHub Release、Raw 文件下载,支持api.github.com,脚本嵌套加速等等
  • 🤖 AI 模型库支持 - 支持 Hugging Face 模型下载加速
  • 🛡️ 智能限流 - IP 限流保护,防止滥用
  • 🚫 仓库审计 - 强大的自定义黑名单,白名单,同时审计镜像仓库,和GitHub仓库
  • 🔍 镜像搜索 - 在线搜索 Docker 镜像
  • 轻量高效 - 基于 Go 语言,单二进制文件运行,资源占用低,优雅的内存清理机制。
  • 🔧 统一配置 - 统一配置管理

🚀 快速开始

Docker部署(推荐)

docker run -d \
  --name hubproxy \
  -p 5000:5000 \
  --restart always \
  ghcr.io/sky22333/hubproxy

一键脚本安装

curl -fsSL https://raw.githubusercontent.com/sky22333/hubproxy/main/install-service.sh | sudo bash

也可以直接下载二进制文件执行./hubproxy使用,无需配置文件即可启动,内置默认配置,支持所有功能。初始内存占用约18M,二进制文件大小约12M

这个命令会:

  • 🔍 自动检测系统架构(AMD64/ARM64)
  • 📥 从 GitHub Releases 下载最新版本
  • ⚙️ 自动配置系统服务
  • 🔄 保留现有配置(升级时)

📖 使用方法

Docker 镜像加速

# 原命令
docker pull nginx

# 使用加速
docker pull yourdomain.com/nginx

# ghcr加速
docker pull yourdomain.com/ghcr.io/sky22333/hubproxy

# 符合Docker Registry API v2标准的仓库都支持

GitHub 文件加速

# 原链接
https://github.com/user/repo/releases/download/v1.0.0/file.tar.gz

# 加速链接
https://yourdomain.com/https://github.com/user/repo/releases/download/v1.0.0/file.tar.gz

# 加速下载仓库
git clone https://yourdomain.com/https://github.com/sky22333/hubproxy.git

⚙️ 配置

config.toml 配置说明

此配置是默认配置,已经内置在程序中了,可以不用添加。

[server]
host = "0.0.0.0"
# 监听端口
port = 5000
# Github文件大小限制(字节),默认2GB
fileSize = 2147483648

[rateLimit]
# 每个IP每小时允许的请求数(注意Docker镜像会有多个层,会消耗多个次数)
requestLimit = 500
# 限流周期(小时)
periodHours = 1.0

[security]
# IP白名单,支持单个IP或IP段
# 白名单中的IP不受限流限制
whiteList = [
    "127.0.0.1",
    "172.17.0.0/16",
    "192.168.1.0/24"
]

# IP黑名单,支持单个IP或IP段
# 黑名单中的IP将被直接拒绝访问
blackList = [
    "192.168.100.1",
    "192.168.100.0/24"
]

[proxy]
# 代理服务白名单(支持GitHub仓库和Docker镜像,支持通配符)
# 只允许访问白名单中的仓库/镜像,为空时不限制
whiteList = []

# 代理服务黑名单(支持GitHub仓库和Docker镜像,支持通配符)
# 禁止访问黑名单中的仓库/镜像
blackList = [
    "baduser/malicious-repo",
    "*/malicious-repo",
    "baduser/*"
]

# 代理配置,支持有用户名/密码认证和无认证模式
# 无认证: socks5://127.0.0.1:1080
# 有认证: socks5://username:password@127.0.0.1:1080
# HTTP 代理示例
# http://username:password@127.0.0.1:7890
# SOCKS5 代理示例
# socks5://username:password@127.0.0.1:1080
# SOCKS5H 代理示例
# socks5h://username:password@127.0.0.1:1080
# 留空不使用代理
proxy = "" 

[download]
# 批量下载离线镜像数量限制
maxImages = 10

# Registry映射配置,支持多种镜像仓库上游
[registries]

# GitHub Container Registry
[registries."ghcr.io"]
upstream = "ghcr.io"
authHost = "ghcr.io/token" 
authType = "github"
enabled = true

# Google Container Registry
[registries."gcr.io"]
upstream = "gcr.io"
authHost = "gcr.io/v2/token"
authType = "google"
enabled = true

# Quay.io Container Registry
[registries."quay.io"]
upstream = "quay.io"
authHost = "quay.io/v2/auth"
authType = "quay"
enabled = true

# Kubernetes Container Registry
[registries."registry.k8s.io"]
upstream = "registry.k8s.io"
authHost = "registry.k8s.io"
authType = "anonymous"
enabled = true

[tokenCache]
# 是否启用缓存(同时控制Token和Manifest缓存)显著提升性能
enabled = true
# 默认缓存时间(分钟)
defaultTTL = "20m"

容器内的配置文件位于 /root/config.toml

脚本部署配置文件位于 /opt/hubproxy/config.toml

为了IP限流能够正常运行,反向代理需要传递IP头用来获取访客真实IP,以caddy为例:

example.com {
    reverse_proxy {
        to 127.0.0.1:5000
        header_up X-Real-IP {remote}
        header_up X-Forwarded-For {remote}
        header_up X-Forwarded-Proto {scheme}
    }
}

cloudflare CDN:

example.com {
    reverse_proxy 127.0.0.1:5000 {
        header_up X-Forwarded-For {http.request.header.CF-Connecting-IP}
        header_up X-Real-IP {http.request.header.CF-Connecting-IP}
        header_up X-Forwarded-Proto https
        header_up X-Forwarded-Host {host}
    }
}

⚠️ 免责声明

  • 本程序仅供学习交流使用,请勿用于非法用途
  • 使用本程序需遵守当地法律法规
  • 作者不对使用者的任何行为承担责任

⭐ 如果这个项目对你有帮助,请给个 Star!⭐

Star History Chart

About

基于Go的自托管轻量级、高性能的多功能代理加速服务,提供 Docker 镜像加速、GitHub 加速、下载离线镜像等功能。单域名实现所有功能,支持仓库审计。流式转发,无缓存。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 51.5%
  • Go 45.7%
  • Shell 2.7%
  • Dockerfile 0.1%
0