A reverse proxy server written in Go. It matches client endpoints to one of multiple backend URLs, selected based on customizable load-balancing strategies.
-
Load Balancing Strategies:
- Round-robin
- Weighted random
- Pure random
-
Ban System: Temporarily disables poorly performing backends based on:
- Response status codes
- Response body keyword matching
-
SOCKS5 Proxy Support: Each backend can be optionally attached to a SOCKS5 tunnel.
-
HTTPS/TLS Support: Configure certificates in the config file.
Go v1.22 or higher is required.
-
Clone the repository:
git clone https://github.com/abswn/revproxy-go.git cd revproxy-go
-
Run tests:
go test ./... -v
-
Build the binary:
go build -o revproxy-go .
-
Run the server:
./revproxy-go
revproxy-go/
├── cmd/ # Future command-line tools
├── configs/
│ ├── config.yaml # Main server configuration
│ └── endpoints/ # Per-site endpoint configurations
├── internal/
│ ├── ban/
│ ├── cert/
│ ├── config/
│ ├── forward/
│ └── strategy/
├── main.go
└── README.md
port: 44562
# Path to certs or leave empty to use without encryption
https_cert_path: ""
https_key_path: ""
log:
level: "info" # Options: debug, info, warn, error, off
output: "logs/output.log" # "stdout" or a file path like "logs/output.log"
format: "text" # "text" or "json"
Multiple YAML files can be used to separate the endpoints logically. All the configs with enabled
flag true
will be active.
enabled: true
endpoints:
"/api":
strategy: round-robin # random, weighted, round-robin
urls:
- url: "https://example.com/api1"
# Optional: socks5, username, password
socks5: "127.0.0.1:1080"
username: "user1"
password: "pass1"
- url: "https://example.com/api2"
- url: "https://example.com/api3"
ban:
- match : ["429", "try after some time"]
duration: 30 # temporarily disables a backend for 30 secs
- match : ["500"]
duration: 3600
"/path":
strategy: weighted
urls:
- url: "https://example.com/api1"
weight: 50 # Required for weighted strategy
- url: "https://example.com/api2"
weight: 30
- url: "https://example.com/api3"
weight: 20
# Applies to all endpoints and is overridden locally
global_ban:
- match: ["429"]
duration: 30 # in seconds
- match: ["503", "out of capacity"]
duration: 3600
-
enabled
: Whether this config file is active -
endpoints
: Map of path to backend strategy and URLs -
strategy
: Can be either round-robin, weighted or pure random -
urls
: List of backend definitionsurl
: Backend target URLsocks5
: Optional SOCKS5 proxy addressweight
: Used only withweighted
strategy
-
ban
/global_ban
: Theglobal_ban
rules apply to all endpoints in the config. The localban
rules add to it or override it. Multiple keywords can be written in the same line.
Start the server and send requests.
curl http://localhost:44562/api
This will use one of the three backend servers to fetch the result. The selection of the backend server is done in round-robin format. If no healthy backends are available and all have been temporarily disabled, the server responds with 503 Service Unavailable
.
Configured via config.yaml
:
level
:debug
,info
,warn
,error
,off
output
:stdout
or path to log fileformat
:text
orjson
- If cert/key paths are provided, they are used.
- Otherwise fallback to non-encrypted HTTP.
MIT License