Configuration
Here are some examples of using basic user/password authentication for leaf nodes (note while this is using accounts it is not using JWTs)
Singleton mode:
With above configuration, if a soliciting server creates a Leafnode connection with url: nats://leaf:secret@host:port
, then the accepting server will bind the leafnode connection to the account “TheAccount”. This account need to exist otherwise the connection will be rejected.
With the above, if a server connects using leaf1:secret@host:port
, then the accepting server will bind the connection to account account1
. If using leaf2
user, then the accepting server will bind to connection to account2
.
If username/password (either singleton or multi-users) is defined, then the connecting server MUST provide the proper credentials otherwise the connection will be rejected.
If no username/password is provided, it is still possible to provide the account the connection should be associated with:
If other form of credentials are used (jwt, nkey or other), then the server will attempt to authenticate and if successful associate to the account for that specific user. If the user authentication fails (wrong password, no such user, etc..) the connection will be also rejected.
Since NATS 2.2.0, Leaf nodes support outbound WebSocket connections by specifying ws
as the scheme component of the remote server URLs:
Note that if a URL has the ws
scheme, all URLs the list must be ws
. You cannot mix and match. Therefore this would be considered an invalid configuration:
To configure Websocket in the remote server, check the Websocket section.