Skip to content

Commit 7e38b2b

Browse files
authored
增加CF-CDN说明
1 parent e3cef1c commit 7e38b2b

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,53 @@ docker run -d \
5555
ghcr.io/sky22333/hub-proxy
5656
```
5757

58+
---
59+
---
60+
61+
62+
<details>
63+
<summary>CF-CDN获取用户真实IP</summary>
64+
65+
66+
- 替换`Caddyfile`配置
67+
68+
```
69+
hub.{$DOMAIN} {
70+
reverse_proxy * ghproxy:5000 {
71+
header_up X-Real-IP {http.request.header.CF-Connecting-IP}
72+
header_up X-Forwarded-For {http.request.header.CF-Connecting-IP}
73+
header_up X-Forwarded-Proto {http.request.scheme}
74+
header_up CF-IPCountry {http.request.header.CF-IPCountry}
75+
}
76+
}
77+
78+
docker.{$DOMAIN} {
79+
@v2_manifest_blob path_regexp v2_rewrite ^/v2/([^/]+)/(manifests|blobs)/(.*)$
80+
handle @v2_manifest_blob {
81+
rewrite * /v2/library/{re.v2_rewrite.1}/{re.v2_rewrite.2}/{re.v2_rewrite.3}
82+
}
83+
84+
reverse_proxy * docker:5000 {
85+
header_up X-Real-IP {http.request.header.CF-Connecting-IP}
86+
header_up X-Forwarded-For {http.request.header.CF-Connecting-IP}
87+
header_up X-Forwarded-Proto {http.request.scheme}
88+
header_up CF-IPCountry {http.request.header.CF-IPCountry}
89+
}
90+
}
91+
92+
ghcr.{$DOMAIN} {
93+
reverse_proxy * ghcr:5000 {
94+
header_up X-Real-IP {http.request.header.CF-Connecting-IP}
95+
header_up X-Forwarded-For {http.request.header.CF-Connecting-IP}
96+
header_up X-Forwarded-Proto {http.request.scheme}
97+
header_up CF-IPCountry {http.request.header.CF-IPCountry}
98+
}
99+
}
100+
```
101+
102+
</details>
103+
104+
58105
---
59106
---
60107

ghproxy/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
const (
19-
sizeLimit = 1024 * 1024 * 1024 * 10 // 允许的文件大小,默认10GB
19+
sizeLimit = 1024 * 1024 * 1024 * 2 // 允许的文件大小,默认2GB
2020
host = "0.0.0.0" // 监听地址
2121
port = 5000 // 监听端口
2222
)

ghproxy/skopeo_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ func cleanupTempFiles() {
10301030
}
10311031

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

0 commit comments

Comments
 (0)