配置
The gateway
configuration block is similar to a cluster
block:
One difference is that instead of routes
you specify gateways
. As expected self-gateway connections are ignored, so you can share gateway configurations with minimal fuss.
Starting a server:
Once all the gateways are up, these clusters of one will forward messages as expected:
On a different session...
The subscriber should print
Gateway
Configuration Block
Gateway
Configuration Blockname
Name for this cluster, all gateways belonging to the same cluster, should specify the same name.
reject_unknown_cluster
If true
, gateway will reject connections from cluster that are not configured in gateways
. It does so by checking if the cluster name, provided by the incomming connection, exists as named gateway. This effectively disables gossiping of new cluster. It does not restrict a configured gateway, thus cluster, from dynamically growing.
gateways
host
Interface where the gateway will listen for incoming gateway connections.
port
Port where the gateway will listen for incoming gateway connections.
listen
Combines host
and port
as <host>:<port>
tls
advertise
Hostport <host>:<port>
to advertise how this server can be contacted by other gateway members. This is useful in setups with NAT.
connect_retries
After how many failed connect attempts to give up establishing a connection to a discovered gateway. Default is 0
, do not retry. When enabled, attempts will be made once a second. This, does not apply to explicitly configured gateways.
authorization
Gateway
Entry
Gateway
EntryThe gateways
configuration block is a list of gateway entries with the following properties:
name
Gateway name.
url
Hostport <host>:<port>
describing where the remote gateway can be reached. If multiple IPs are returned, one is randomly selected.
urls
A list of url
strings.
tls
By using urls
and an array, you can specify a list of endpoints that form part of a cluster as below. A NATS Server will pick one of those addresses randomly and only establish a single outbound gateway connection to one of the members from another cluster:
TLS Entry
In addition to the normal TLS configuration advice, bear in mind that TLS keys and certificates for multiple clusters, or servers in different locations, rarely rotate at the exact same time and that Certificate Authorities do roll between multiple Intermediate certificates.
If using a certificate bundle which accompanied the issuance of a certificate then the CA in that bundle will typically be for just that certificate. Using only that CA as the CA for gateway authentication is ill-advised. You should ensure that you allow for rolling between Certificate Authorities, even if only between multiple CAs from the same organization entity, and use a separate certificate bundle for verification of peers. This way when DC-B rolls before DC-A, it will not be cut off from your supercluster.
最后更新于