- daemonize() 使用 python -m 方式启动子进程,避免 console_scripts 入口点路径问题 - daemonize() 在 Popen 后调用 sys.exit(0) 让父进程退出 - 添加 --_daemon_child 隐藏参数,子进程跳过 daemonize 直接运行服务 - 将 _run_daemonized 重命名为 _run_child,职责更清晰
jianda-proxy
HTTP proxy for Gitea LFS -- rewrites Host header to bypass ICP domain blocking.
Repository: ssh://git@git.zz.com:2222/Developer/jianda-proxy.git
Background
Internal Gitea is exposed via a reverse tunnel on a Tencent Cloud server. The client resolves the domain via hosts file to the cloud IP. SSH clone works fine, but LFS file downloads go over HTTP. Tencent Cloud detects the unregistered domain from the Host header and blocks the request with a 302 redirect.
This proxy rewrites the Host header on all requests to the upstream IP address, bypassing the ICP block.
Installation
uv tool install git+ssh://git@git.zz.com:2222/Developer/jianda-proxy.git
CLI Commands
Start the proxy
# Start as a background daemon (default)
jianda-proxy start
# Run in the foreground (useful for debugging)
jianda-proxy start --foreground
# Override the listen port
jianda-proxy start --port 8080
Stop the proxy
jianda-proxy stop
Check status
jianda-proxy status
Manage configuration
# View all config values
jianda-proxy config list
# Get a specific value
jianda-proxy config get upstream_host
# Set a value
jianda-proxy config set listen_port 8080
# Show config file path
jianda-proxy config path
Configuration
Default values (written to config file on first run):
| Key | Default | Description |
|---|---|---|
| remote_domain | git.zz.com | Domain to intercept |
| upstream_host | 62.234.191.215 | Upstream server IP |
| upstream_port | 3000 | Upstream server port |
| listen_host | 127.0.0.1 | Proxy listen address |
| listen_port | 13000 | Proxy listen port |
Config file location: ~/.config/jianda-proxy/config.ini (or %APPDATA%\jianda-proxy\config.ini on Windows).
Example Workflow
- Install and start the proxy:
jianda-proxy start
- Configure Git to route LFS requests through the proxy (one-time setup):
git config --global http.http://git.zz.com:3000/.proxy http://127.0.0.1:13000
- Clone as usual:
git clone ssh://git@git.zz.com:2222/Developer/jianda-proxy.git
LFS downloads will be routed through the proxy transparently.
Running without installation
# Via uv
uv run python -m jianda_proxy start --foreground
# Via python directly
python -m jianda_proxy start --foreground
Root Cause Fix
Setting ROOT_URL in Gitea's app.ini to the IP address (e.g. http://62.234.191.215:3000) eliminates the need for this proxy entirely.