增加CF-CDN说明

This commit is contained in:
NewName
2025-05-18 14:45:45 +08:00
parent 92b26bca67
commit 5d41fa979e
3 changed files with 49 additions and 2 deletions

View File

@@ -55,6 +55,53 @@ docker run -d \
ghcr.io/sky22333/hub-proxy
```
---
---
<details>
<summary>CF-CDN获取用户真实IP</summary>
- 替换`Caddyfile`配置
```
hub.{$DOMAIN} {
reverse_proxy * ghproxy:5000 {
header_up X-Real-IP {http.request.header.CF-Connecting-IP}
header_up X-Forwarded-For {http.request.header.CF-Connecting-IP}
header_up X-Forwarded-Proto {http.request.scheme}
header_up CF-IPCountry {http.request.header.CF-IPCountry}
}
}
docker.{$DOMAIN} {
@v2_manifest_blob path_regexp v2_rewrite ^/v2/([^/]+)/(manifests|blobs)/(.*)$
handle @v2_manifest_blob {
rewrite * /v2/library/{re.v2_rewrite.1}/{re.v2_rewrite.2}/{re.v2_rewrite.3}
}
reverse_proxy * docker:5000 {
header_up X-Real-IP {http.request.header.CF-Connecting-IP}
header_up X-Forwarded-For {http.request.header.CF-Connecting-IP}
header_up X-Forwarded-Proto {http.request.scheme}
header_up CF-IPCountry {http.request.header.CF-IPCountry}
}
}
ghcr.{$DOMAIN} {
reverse_proxy * ghcr:5000 {
header_up X-Real-IP {http.request.header.CF-Connecting-IP}
header_up X-Forwarded-For {http.request.header.CF-Connecting-IP}
header_up X-Forwarded-Proto {http.request.scheme}
header_up CF-IPCountry {http.request.header.CF-IPCountry}
}
}
```
</details>
---
---

View File

@@ -16,7 +16,7 @@ import (
)
const (
sizeLimit = 1024 * 1024 * 1024 * 10 // 允许的文件大小,默认10GB
sizeLimit = 1024 * 1024 * 1024 * 2 // 允许的文件大小,默认2GB
host = "0.0.0.0" // 监听地址
port = 5000 // 监听端口
)

View File

@@ -1030,7 +1030,7 @@ func cleanupTempFiles() {
}
// 如果总大小超过10GB清理所有文件防止恶意下载导致磁盘爆满
if totalSize > 10*1024*1024*1024 { // 15GB
if totalSize > 10*1024*1024*1024 {
fmt.Printf("临时文件总大小超过10GB (当前: %.2f GB),清理所有文件\n", float64(totalSize)/(1024*1024*1024))
cleanAll()
} else {