Initial commit

This commit is contained in:
2026-05-28 17:11:46 +08:00
commit 40b52f6391
2 changed files with 130 additions and 0 deletions

44
README.md Normal file
View File

@@ -0,0 +1,44 @@
# jianda-proxy
本地 HTTP 代理,解决腾讯云对未备案域名拦截导致的 Git LFS 下载失败问题。
## 背景
内网 Gitea 通过反向隧道暴露到腾讯云,客户端通过 `hosts` 文件将域名指向云服务器 IP。SSH clone 正常,但 LFS 文件下载走 HTTP 协议,腾讯云检测到域名未备案,基于 Host 头拦截请求返回 302。
本代理将所有发往 `git.zz.com` 的请求的 Host 头改写为 IP 地址,绕过备案拦截。
## 使用方法
### 1. 启动代理
```bash
python3 lfs-proxy.py [port]
```
默认监听 `127.0.0.1:13000`,可指定其他端口。
### 2. 配置 Git 走代理(只需一次)
```bash
git config --global http.http://git.zz.com:3000/.proxy http://127.0.0.1:13000
```
### 3. 正常 clone
```bash
git clone ssh://git@git.zz.com:2222/Mustapha/lfs-test.git
```
## 原理
代理同时支持两种模式:
- **正向代理**:接收 `GET http://git.zz.com:3000/...` 形式的请求,改写 Host 头转发到上游
- **反向代理**:接收 `GET /...` 形式的请求,直接转发到上游并附带 IP Host 头
上游地址硬编码为 `62.234.191.215:3000`,可在脚本顶部修改。
## 根治方案
在 Gitea 服务端 `app.ini` 中将 `ROOT_URL``http://git.zz.com:3000` 改为 `http://62.234.191.215:3000`,可从根源解决,无需代理。