1
0
mirror of https://github.com/taigrr/nats.docs synced 2025-01-18 04:03:23 -08:00
nats.docs/nats_server/configuration.md
Alberto Ricart 28dfe4b752 wip
2019-05-15 14:12:30 -05:00

1.3 KiB

Configuration File Format

The NATS server products provide a flexible configuration format that combines the best of traditional formats and newer styles such as JSON and YAML.

The config file supports the following syntax:

  • Lines can be commented with # and //
  • Values can be assigned to properties with:
    • Equals sign: foo = 2
    • Colon: foo: 2
    • Whitespace: foo 2
  • Arrays are enclosed in brackets: [...]
  • Maps are enclosed in braces: {...}
  • Maps can be assigned with no key separator
  • Semicolons can be used as terminators

Variables

Server configurations can specify variables. Variables allow you to reference a value from one or more sections in the configuration.

Variables:

  • Are block scoped
  • Are referenced with a $ prefix.
  • Can be resolved from the environment variables having the same name

If the environment variable value begins with a number you may have trouble resolving it depending on the server version you are running.

# Define a variable in the config
TOKEN: "secret"

# Reference the variable
authorization {
	token: $TOKEN
}

A similar configuration, but this time, the value is in the environment:

# TOKEN should be defined in the environment
authorization {
	token: $TOKEN
}

export TOKEN="hello"; nats-server -c /config/file