ProxyGate is a simple yet powerful Golang-based HTTP proxy server that routes requests through a pool of provided proxy servers. It supports both HTTP and SOCKS5 proxies, offering flexible and secure request forwarding.
- HTTP Proxy Server: Offers a simple HTTP proxy interface.
- Proxy Pool: Reads and parses a list of proxies from a file, supporting various formats.
- Random Proxy Selection: Randomly selects a proxy from the pool for each request.
- Sticky Sessions: Honors the
X-Proxy-Sessionheader to consistently reuse the same upstream proxy. - Basic Authentication: Secures the proxy server with a username and password.
- Logging: Logs each request and the selected proxy for easy debugging.
cmd/proxygate: CLI entrypoint used to build the executable.internal/app: Runtime orchestration that wires configuration, proxy pool, and server.internal/config: Parses command-line flags and environment variables.internal/auth: Utilities for working with credentials and authorization headers.internal/proxy: Proxy definitions, parsing logic, and pool management.internal/server: HTTP proxy server runtime built on top ofgithub.com/elazarl/goproxy.
- Go 1.23 or newer or Docker
- A list of proxy servers in
proxy_list.txtformat
docker run -d -p 8080:8080 -e PROXY_USER=yourUsername -e PROXY_PASS=yourPassword -v $(pwd)/proxy_list.txt:/app/proxy_list.txt --name proxygate ghcr.io/rebel028/proxygate:latest-
Clone the Repository
git clone https://github.com/Rebel028/proxygate.git cd proxygate -
Build the Project
go build -o proxygate
-
Run the Server
Supply basic authentication credentials via command-line flags or environment variables:
./proxygate -user yourUsername -pass yourPassword
Or set environment variables:
export PROXY_USER=yourUsername export PROXY_PASS=yourPassword ./proxygate
The proxy_list.txt file should include proxies in the following formats:
ip:portip:port:username:passwordhttp://ip:porthttp://username:password@ip:porthttps://ip:porthttps://username:password@ip:portsocks://ip:portsocks://username:password@ip:portsocks4://ip:portsocks4://username:password@ip:portsocks5://ip:portsocks5://username:password@ip:port
Use any HTTP client to send requests through the proxy server running on localhost:8080, e.g., with curl:
curl -x http://yourUsername:yourPassword@localhost:8080 https://ifconfig.meNote: Ensure that your proxy servers are correctly listed in proxy_list.txt and reachable from your network.
-
Command-line Flags:
-user: Username for basic authentication-pass: Password for basic authentication-listen: Address for the proxy listener (default:8080)-proxy-file: Path to the proxy list file (defaultproxy_list.txt)-verbose: Enable verbose proxy logging
-
Environment Variables:
PROXY_USER: Alternative way to set the usernamePROXY_PASS: Alternative way to set the passwordPROXY_LISTEN: Listener address (e.g.:8080,0.0.0.0:8080)PROXY_FILE: Path to the proxy list filePROXY_VERBOSE: Enable verbose proxy logging (true/1/yes/on)
Both the username and password are required when enabling authentication. Supplying only one of them results in a startup error.
Flags override environment variables. For example, the following starts on :9090 regardless of PROXY_LISTEN:
PROXY_LISTEN=":8080" PROXY_FILE="proxy_list.txt" PROXY_VERBOSE="true" ./proxygate -listen :9090This project is licensed under the MIT License. See the LICENSE file for details.