Configuration

Environment Variables

Complete reference for all SNI Router environment variables.

Environment Variables

SNI Router is configured entirely via environment variables. The entrypoint.sh script reads these at container start, generates haproxy.cfg, validates it, and then starts HAProxy. If any required variable is missing or a value is malformed, the container exits with an error.

TLS / SNI routing

VariableRequiredDefaultDescription
SNI_LISTEN_PORTNo443Port HAProxy listens on for TLS/SNI traffic.
SNI_ROUTE_NAt least oneTLS routing rule: hostname:backend_ip:backend_port. N must be consecutive integers starting at 1 (SNI_ROUTE_1, SNI_ROUTE_2, …).
SNI_ROUTESNoMultiline alternative to SNI_ROUTE_N. One hostname:ip:port per line; # comments and blank lines are ignored. Processed after SNI_ROUTE_N. Useful with Docker Compose block-scalar YAML (|).
SNI_DEFAULTYesDefault backend when no SNI rule matches: ip:port.

Wildcard hostnames are supported: *.example.com matches any subdomain. See Routing Rules for details on how exact and wildcard rules interact.

HTTP frontend

The HTTP frontend (port 80) allows SNI Router to forward Let's Encrypt http-01 ACME challenges to the correct backend and redirect all other plain HTTP requests to HTTPS.

VariableRequiredDefaultDescription
SNI_HTTP_REDIRECTNofalseEnable the HTTP frontend. All unmatched requests are 301-redirected to HTTPS. Activated automatically if any HTTP_ROUTE_* variable is set.
SNI_HTTP_PORTNo80Port for the HTTP frontend.
HTTP_ROUTE_NNoHTTP routing rule: hostname:backend_ip:backend_port.
HTTP_ROUTESNoMultiline alternative to HTTP_ROUTE_N (same format as SNI_ROUTES).

Plain TCP routing

Each TCP_ROUTE_N creates an independent HAProxy frontend that forwards all traffic arriving on listen_port to the specified backend — no SNI inspection.

VariableRequiredDefaultDescription
TCP_ROUTE_NNoTCP routing rule: listen_port:backend_ip:backend_port. Remember to expose listen_port in your ports: mapping.

PROXY protocol

VariableRequiredDefaultDescription
PROXY_PROTOCOLNofalseSend PROXY protocol v2 header to all backends (true/false). Backends must be configured to accept it. See Traefik integration.

Health checks

By default every backend is TCP-checked every 2 seconds (inter 2s fall 3 rise 2). The variables below replace the plain TCP check with an HTTPS application-level check for individual backends.

VariableRequiredDefaultDescription
SNI_HEALTH_NNo(TCP)HTTPS health-check path for SNI_ROUTE_N (e.g. /health). HAProxy sends GET <path> over TLS (no cert verification) with Host: <hostname>.
SNI_HEALTH_<norm>No(TCP)HTTPS health-check path for an SNI_ROUTES entry. <norm> is the hostname with ., *, - replaced by _ (e.g. SNI_HEALTH_app1_example_com=/health).
SNI_DEFAULT_HEALTHNo(TCP)HTTPS health-check path for the SNI_DEFAULT backend.
TCP_HEALTH_NNo(TCP)HTTPS health-check path for TCP_ROUTE_N.

See Health Checks for detailed examples.

HAProxy stats UI

VariableRequiredDefaultDescription
STATS_ENABLEDNofalseEnable the built-in HAProxy stats web dashboard.
STATS_PORTNo8404Port for the stats UI. Access at http://<local-ip>:<STATS_PORT>/stats.
STATS_PASSWORDNo(none)Password for the admin user. Leave empty to disable authentication.
Always bind the stats port to a local network interface — never to 0.0.0.0 on a public host. In docker-compose.yml: "192.168.1.5:8404:8404" instead of "8404:8404".
Copyright © 2026