A simple proxy forwarder written in Go. Routes requests through different upstream proxies based on domain rules.
- Local HTTP proxy server
- Route requests based on domain matching
- Support for multiple upstream proxy types:
- HTTP proxies
- SOCKS5 proxies (with authentication)
- Direct connections
- YAML-based configuration
go build -o broxyCreate a rules.yaml file (see rules.yaml.example for reference):
server:
listen: 0.0.0.0
port: 3128
proxies:
- name: proxy_google
type: http
host: proxy1.example.com
port: 8080
- name: proxy_reddit
type: socks5
host: proxy2.example.com
port: 1080
auth:
username: user
password: pass
- name: direct
type: direct
rules:
- match: domain
value: ".google.com"
proxy: proxy_google
- match: domain
value: ".reddit.com"
proxy: proxy_reddit
- match: ip
value: "192.168.1.0/24"
proxy: proxy_google
- match: ip
value: "10.0.0.1"
proxy: proxy_reddit
- match: default
proxy: direct# Run with default config file (~/.config/broxy/rules.yaml)
./broxy run
# Run with custom config file
./broxy run -config /path/to/config.yamlCreate a LaunchAgent plist file at ~/Library/LaunchAgents/com.broxy.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.broxy</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/broxy</string>
<string>run</string>
<string>-config</string>
<string>/Users/YOUR_USERNAME/.config/broxy/rules.yaml</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/Users/YOUR_USERNAME/.config/broxy/broxy.log</string>
<key>StandardErrorPath</key>
<string>/Users/YOUR_USERNAME/.config/broxy/broxy.error.log</string>
</dict>
</plist>Then load the service:
launchctl load ~/Library/LaunchAgents/com.broxy.plistTo stop the service:
launchctl unload ~/Library/LaunchAgents/com.broxy.plistlisten: IP address to listen on (default: 0.0.0.0)port: Port to listen on (default: 3128)
name: Unique identifier for the proxytype: Proxy type (http,socks5, ordirect)host: Proxy server hostnameport: Proxy server portauth: (optional) Authentication credentialsusername: Usernamepassword: Password
match: Rule type (domain,ip, ordefault)value: Match pattern:- For
domainrules: Domain suffix (e.g.,.google.commatchesgoogle.comandwww.google.com) - For
iprules: Exact IP (e.g.,1.2.3.4) or CIDR range (e.g.,192.168.0.0/16)
- For
proxy: Name of the proxy to use
- Broxy starts a local HTTP proxy server
- When a request comes in, the router checks the domain against configured rules
- The request is forwarded through the matching upstream proxy
- If no specific rule matches, the default rule is used
- SOCKS5 proxies only work for HTTPS (CONNECT method); plain HTTP through SOCKS5 is not supported