Releases: LZUOSS/gh-proxy
Releases · LZUOSS/gh-proxy
Release v0.5.0
GitHub Reverse Proxy v0.5.0
Bug Fixes
🐛 Fixed 404 and 400 errors for full GitHub URLs with base_path configured
Completely resolved issues where full GitHub URLs with schemes (https://, http://) were failing when used with a base path configuration.
The Problem:
When base_path was configured (e.g., /ghproxy), requests like:
GET /ghproxy/https://github.com/golang/go/archive/refs/tags/go1.26rc3.tar.gz
Were failing with:
- Initial issue: 404 Not Found (route didn't match)
- After first fix: Router panic (invalid route pattern)
- After second fix: Router panic (route conflicts)
- After third fix: 400 Bad Request (base path not stripped)
The Solution:
Implemented a complete middleware-based approach that:
- ✅ Intercepts requests containing
://before routing (avoids route conflicts) - ✅ Strips the base path from the request path using config values
- ✅ Temporarily modifies
c.Request.URL.Pathfor the URL handler - ✅ Sets context flags to prevent double base path stripping
- ✅ Restores the original path after handling for proper logging/metrics
How It Works:
// Middleware detects full URLs and strips base path
if strings.Contains(path, "://") {
if strings.HasPrefix(path, "/ghproxy/") {
path = strings.TrimPrefix(path, "/ghproxy")
c.Request.URL.Path = path // Now: /https://github.com/...
}
urlHandler.Handle(c) // Receives: https://github.com/... (after leading slash removed)
}This now works perfectly:
curl http://your-server:8080/ghproxy/https://github.com/golang/go/archive/refs/tags/go1.26rc3.tar.gz
# ✅ Returns the archive file from GitHubFeatures
- ✅ Full GitHub URL support with proper base path handling
- ✅ Path-based deployment (deploy on subpaths like
/ghproxy) - ✅ HTTP/HTTPS/SOCKS5 proxy support
- ✅ Hybrid memory + disk caching with ARC eviction
- ✅ IP-based and token-based rate limiting
- ✅ Token-based and basic authentication
- ✅ SSRF protection and security headers
- ✅ Prometheus metrics
- ✅ SSH proxy for Git operations
Installation
Download the appropriate binary for your platform below.
Linux (AMD64)
wget https://github.com/LZUOSS/gh-proxy/releases/download/v0.5.0/gh-proxy-v0.5.0-linux-amd64.tar.gz
tar -xzf gh-proxy-v0.5.0-linux-amd64.tar.gz
sudo chmod +x gh-proxy-v0.5.0-linux-amd64
sudo mv gh-proxy-v0.5.0-linux-amd64 /usr/local/bin/gh-proxymacOS (ARM64 - Apple Silicon)
wget https://github.com/LZUOSS/gh-proxy/releases/download/v0.5.0/gh-proxy-v0.5.0-darwin-arm64.tar.gz
tar -xzf gh-proxy-v0.5.0-darwin-arm64.tar.gz
chmod +x gh-proxy-v0.5.0-darwin-arm64
sudo mv gh-proxy-v0.5.0-darwin-arm64 /usr/local/bin/gh-proxyWindows (AMD64)
Download gh-proxy-v0.5.0-windows-amd64.zip and extract.
Quick Start
# Run with default config
gh-proxy
# Run with custom config
gh-proxy -config /path/to/config.yamlConfiguration Example
To enable full URL support with a base path:
server:
base_path: "/ghproxy" # All routes will be prefixed with /ghproxy
http_port: 8080Usage Examples
With the above config, all these work:
# Full URL with scheme
curl http://localhost:8080/ghproxy/https://github.com/golang/go/archive/refs/tags/go1.26rc3.tar.gz
# URL without scheme
curl http://localhost:8080/ghproxy/github.com/golang/go/archive/refs/tags/go1.26rc3.tar.gz
# Traditional path-based
curl http://localhost:8080/ghproxy/golang/go/archive/refs/tags/go1.26rc3.tar.gzDocumentation
See README.md for full configuration options.
Checksums
See SHA256SUMS for file checksums.
Full Changelog: v0.4.0...v0.5.0