Skip to main content

Configuration

The proxy is configured through environment variables, all optional. A .env file is loaded if present.

VariableValueDefault
LOG_LEVELpanic, fatal, error, warn, info, debug, traceinfo
PORTnumber8080
METRICS_PORTnumber9000
ENABLE_METRICSbooleantrue
ENABLE_PPROFbooleanfalse
BUFFER_SIZEnumber50
OUTBOUND_IPIP addressempty
BIND_IPIP address0.0.0.0
DISCORD_URLURL with no pathhttps://discord.com
REQUEST_TIMEOUTnumber (milliseconds)5000
CLUSTER_PORTnumber7946
CLUSTER_MEMBERScomma separated listempty
CLUSTER_ADVERTISE_ADDRaddress, host name or autoempty
CLUSTER_DNSdomain nameempty
MAX_BEARER_COUNTnumber1024
DISABLE_HTTP_2booleantrue
BOT_RATELIMIT_OVERRIDEScomma separated listempty
DISABLE_GLOBAL_RATELIMIT_DETECTIONbooleantrue

Server​

LOG_LEVEL​

Log level, passed as is to logrus.

PORT and METRICS_PORT​

Ports the proxy listens on for requests and for its metrics.

ENABLE_METRICS and ENABLE_PPROF​

Enables metrics (turning them off saves a little) and profiling.

BIND_IP​

Address the HTTP server listens on, for requests and metrics alike. 127.0.0.1 only accepts local connections, 10.0.0.42 only those from the LAN.

BUFFER_SIZE​

Size of the Go channels that order requests. Lowering it saves memory, but once a channel is full, requests fight for the next free spot: under heavy load, part of them are no longer sent in order.

Discord​

DISCORD_URL​

Where requests go, as a scheme and a host with no path. Used to put the proxy in front of a Discord simulator or a recording proxy.

OUTBOUND_IP​

Local address requests to Discord leave from, for example 120.121.122.123.

REQUEST_TIMEOUT​

How long to wait for Discord's answer, not counting time spent waiting on rate limits. Past it, the proxy answers 408.

DISABLE_HTTP_2​

Disables HTTP/2 for requests to Discord, because of a few issues in Go's HTTP/2 support. Does not affect the proxy's own server.

MAX_BEARER_COUNT​

Maximum number of Bearer token queues, kept in an LRU cache. A request is never interrupted when its queue is evicted, but a size too low can raise 429s if a token has many requests queued.

Global limit​

BOT_RATELIMIT_OVERRIDES​

Global requests per second limit, for bots whose limit Discord raised. Without it, every bot is limited to 50, the value Discord documents.

Format: the bot's user ID (not its application ID) and its limit, separated by :, with no spaces:

BOT_RATELIMIT_OVERRIDES=392827169497284619:100,227115752396685313:80

DISABLE_GLOBAL_RATELIMIT_DETECTION​

Set to false, the proxy infers the global limit from /gateway/bot (50 for a concurrency of 1, 500 for 16, and a formula above). Discord does not document that relation, and /gateway/bot is limited to 2 requests every 5 seconds, which the bot's shards need when they start: detection is therefore off by default in our fork. Prefer BOT_RATELIMIT_OVERRIDES.

Cluster​

See High availability for how it works.

CLUSTER_PORT​

Port used to talk to the other cluster members.

CLUSTER_MEMBERS​

Known cluster members, comma separated, with an optional port (CLUSTER_PORT otherwise). No need to list them all: the others are discovered through a gossip protocol. Takes precedence over CLUSTER_DNS.

CLUSTER_MEMBERS=10.0.0.2,10.0.0.3:7244

CLUSTER_DNS​

Domain name that resolves to several cluster members, the recommended method on Kubernetes (with a headless service, for example nirn-headless.default.svc.cluster.local). DNS carries no port: every node must then use the same CLUSTER_PORT.

CLUSTER_ADVERTISE_ADDR​

Address this node advertises to the others. Empty, memberlist picks it alone, which inside a container can give an unreachable address. Set an IP address, a host name, or auto to take the first non-loopback IPv4 address.

Unstable variables​

DISABLE_401_LOCK​

The proxy locks a queue for good after a 401 during normal operation. This variable disables the lock, but not its logging. It may be removed at any time.