NATS Server Configuration¶
The NATS server can be configured using both a configuration file and environment variables.
Environment Variables¶
The NATS server configuration is done via environment variables. The following table lists all available environment variables and their default values.
Environment Variable | Default Value | Description |
---|---|---|
NATS_HOST |
localhost |
The host of the NATS server. |
NATS_PORT |
4222 |
The port of the NATS server. |
Configuration File¶
The NATS server can also be configured using a configuration file. To use a configuration file, you need to pass the -c
flag to the NATS server:
You can find a full reference of the NATS server configuration in the NATS documentation.
For Telestion, the following settings are of special interest:
websocket
- This section configures the WebSocket interface of the NATS server. It’s used by the Telestion frontend to connect to the NATS server.authorization
- This section configures who can publish and subscribe to which subjects.authorization.users
- This section configures the user accounts that can connect to the NATS server. It’s used to configure the user accounts that can connect to the NATS server. As of right now, Telestion exclusively supports username/password-based authentication.
Development Configuration¶
The following configuration is a good starting point for development.
Danger
Do not use this configuration in production! It’s only meant for development.
There are several problems with this configuration that make it unsuitable for production:
- it doesn’t use TLS for the websocket interface, meaning that all communication is unencrypted
- it doesn’t have any authentication or authorization configured, meaning that anyone can connect to the NATS server and publish/subscribe to any subject
In essence, if you were to use this configuration in production, you would have a NATS server that is publicly accessible and allows anyone with access to your server to publish/subscribe to any subject!