Files
jianda-proxy/README.md
tech 0023b57596 docs: update README for CLI tool usage, remove old script
- Rewrite README.md with CLI usage instructions
- Add __main__.py for `python -m jianda_proxy` support
- Clean up unused imports in config.py and test_config.py
- Add pytest dev dependency to pyproject.toml
- Remove lfs-proxy.py (replaced by modular CLI tool)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-28 17:58:19 +08:00

113 lines
2.6 KiB
Markdown

# jianda-proxy
HTTP proxy for Gitea LFS -- rewrites Host header to bypass ICP domain blocking.
## 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
```bash
# Install as a global CLI tool (recommended)
uv tool install .
# Or with pip
pip install .
```
## CLI Commands
### Start the proxy
```bash
# 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
```bash
jianda-proxy stop
```
### Check status
```bash
jianda-proxy status
```
### Manage configuration
```bash
# 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
1. Install and start the proxy:
```bash
jianda-proxy start
```
2. Configure Git to route LFS requests through the proxy (one-time setup):
```bash
git config --global http.http://git.zz.com:3000/.proxy http://127.0.0.1:13000
```
3. Clone as usual:
```bash
git clone ssh://git@git.zz.com:2222/your-repo.git
```
LFS downloads will be routed through the proxy transparently.
## Running without installation
```bash
# 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.