Mekong Tunnel Logo
MEKONG

Configuration

All environment variables for configuring the MekongTunnel server.

Configuration

The MekongTunnel server is configured entirely via environment variables. No config file required.

Setup

cp .env.example .env
nano .env

Variables

VariableDefaultDescription
DOMAINmuyleanging.comYour domain โ€” tunnels become subdomains of this
SSH_ADDR:22SSH server listen address
HTTP_ADDR:80HTTP redirect server address
HTTPS_ADDR:443HTTPS proxy server address
STATS_ADDR127.0.0.1:9090Metrics endpoint (localhost only)
MAX_TUNNELS_PER_IP1000Max concurrent tunnels per IP (v1.4.1+)
MAX_TOTAL_TUNNELS0Max total active tunnels โ€” 0 means unlimited (v1.4.7+)
MAX_CONNECTIONS_PER_MINUTE0Max new SSH connections per IP per minute โ€” 0 means unlimited (v1.4.7+)
HOST_KEY_PATHhost_keySSH host key file path (auto-generated if missing)
TLS_CERT/certs/fullchain.pemTLS certificate path (inside container)
TLS_KEY/certs/privkey.pemTLS private key path (inside container)

Example .env

# Domain โ€” tunnels become subdomains of this
DOMAIN=yourdomain.com
 
# Server ports
SSH_ADDR=:22
HTTP_ADDR=:80
HTTPS_ADDR=:443
STATS_ADDR=127.0.0.1:9090
 
# Per-IP tunnel limit (default: 1000)
MAX_TUNNELS_PER_IP=1000
 
# Total tunnel limit โ€” 0 means unlimited (default: 0)
MAX_TOTAL_TUNNELS=0
 
# Max new SSH connections per IP per minute โ€” 0 means unlimited (default: 0)
MAX_CONNECTIONS_PER_MINUTE=0
 
# SSH host key (auto-generated on first run)
HOST_KEY_PATH=/host_key
 
# TLS certificates
TLS_CERT=/certs/fullchain.pem
TLS_KEY=/certs/privkey.pem

Hard-coded limits

The following limits are compile-time constants (in internal/config/config.go). To change them, rebuild the binary:

ConstantValueDescription
MaxTotalTunnels0 (unlimited)Max total active tunnels โ€” 0 disables the cap
RequestsPerSecond10Per-tunnel HTTP rate limit
BurstSize20Per-tunnel burst allowance
MaxConnectionsPerMinute0 (unlimited)New SSH connections per IP per minute โ€” 0 disables the cap
BlockDurationdisabledAuto-blocking is off by default since v1.4.8
RateLimitViolationsMax0 (disabled)Auto-block threshold โ€” 0 disables auto-blocking
InactivityTimeout2 hoursTunnel closes after this idle period
MaxTunnelLifetime24 hoursMax tunnel duration regardless of activity
MaxRequestBodySize1 GBMax incoming request body size
MaxResponseBodySize1 GBMax response body size
WebSocketIdleTimeout2 hoursWebSocket idle timeout
MaxWebSocketTransfer0 (unlimited)Max bytes per WebSocket direction โ€” 0 disables the cap

Running multiple instances

# Production instance
DOMAIN=yourdomain.com ./bin/mekongtunnel
 
# Dev instance on alternate ports
SSH_ADDR=:2223 \
HTTP_ADDR=:8080 \
HTTPS_ADDR=:8443 \
STATS_ADDR=127.0.0.1:9091 \
DOMAIN=yourdomain.com \
./bin/mekongtunnel

Connect to the dev instance via raw SSH:

ssh -t -R 80:localhost:5173 yourdomain.com -p 2223