tyk-gateway
folder and by default is called tyk.conf
, though it can be renamed and specified using the --conf
flag. Environment variables are created from the dot notation versions of the JSON objects contained with the config files.
To understand how the environment variables notation works, see Environment Variables.
All the Gateway environment variables have the prefix TYK_GW_
. The environment variables will take precedence over the values in the configuration file.
tyk lint
command which will validate your tyk.conf
file and validate it for syntax correctness, misspelled attribute names or format of values. The Syntax can be:
tyk lint
or tyk --conf=path lint
If --conf
is not used, the first of the following paths to exist is used:
./tyk.conf
/etc/tyk/tyk.conf
string
string
int
string
int
string
string
string
bool
true
, public_key_path
can be ignored.
string
bool
string
bool
security.certificates.control_api
section
map[string]string
map[string]string
ab23ef123
for requests to the example.com
upstream and /certs/default.pem
for all other upstreams then:
In tyk.conf
you would configure "security": {"certificates": {"upstream": {"*": "/certs/default.pem", "example.com": "ab23ef123"}}}
And if using environment variables you would set this to *:/certs/default.pem,example.com:ab23ef123
.
[]string
[]string
[]string
int
int
bool
bool
bool
/apple
will route to /app
, the current default behavior,/app
only responds to /app
, /app/
and /app/*
but not /apple
bool
/json
will only match request URLs that begin with /json
, rather than matching any URL containing /json
.
The gateway checks the request URL against several variations depending on whether path versioning is enabled:
/listen-path/v4/json
/listen-path/json
/json
/
, the gateway prepends ^
before performing the check, ensuring a true prefix match.
For patterns that start with ^
, the gateway will already perform prefix matching so EnablePathPrefixMatching will have no impact.
This option allows for more specific and controlled routing of API requests, potentially reducing unintended matches. Note that you may need to adjust existing route definitions when enabling this option.
Example:
With wildcard matching, /json
might match /api/v1/data/json
.
With prefix matching, /json
would not match /api/v1/data/json
, but would match /json/data
.
Combining EnablePathPrefixMatching with EnablePathSuffixMatching will result in exact URL matching, with /json
being evaluated as ^/json$
.
bool
/json
will only match request URLs that end with /json
, rather than matching any URL containing /json
.
The gateway checks the request URL against several variations depending on whether path versioning is enabled:
/listen-path/v4/json
/listen-path/json
/json
$
, the gateway will already perform suffix matching so EnablePathSuffixMatching will have no impact. For all other patterns, the gateway appends $
before performing the check, ensuring a true suffix match.
This option allows for more specific and controlled routing of API requests, potentially reducing unintended matches. Note that you may need to adjust existing route definitions when enabling this option.
Example:
With wildcard matching, /json
might match /api/v1/json/data
.
With suffix matching, /json
would not match /api/v1/json/data
, but would match /api/v1/json
.
Combining EnablePathSuffixMatching with EnablePathPrefixMatching will result in exact URL matching, with /json
being evaluated as ^/json$
.
bool
bool
CertsData
ssl_certificates
instead.
[]string
string
uint16
uint16
bool
int
bool
http://myapi.com/get/http://example.com
.
bool
[]string
int64
Content-Length
header, this is directly compared against MaxRequestBodySize
.Content-Length
header is not provided, the Request body is read in chunks to compare total size against MaxRequestBodySize
.string
bool
int64
bool
bool
true
you are able to search for keys only by keyID or key hash (if hash_keys
is also set to true
)
Note that if hash_keys
is also set to true
then the keyID will not be provided for APIs secured using basic auth. In this scenario the only search option would be to use key hash
If you are using the Tyk Dashboard, you must configure this setting with the same value in both Gateway and Dashboard
string
string
[]string
bool
int
string
string
file
to look in the file system for a definition file. Set to service
to use the Dashboard service.
string
policies.policy_source
is set to service
.
Set this to the URL of your Tyk Dashboard installation. The URL needs to be formatted as: http://dashboard_host:port.
string
policies.policy_source
is either set
to file
or an empty string. If policies.policy_path
is not set, then Tyk will load policies
from the JSON file specified by policies.policy_record_name
.
bool
true
, then the id parameter in a stored policy (or imported policy using the Dashboard API), will be used instead of the internal ID.
This option should only be used when moving an installation to a new database.
string
policies.policy_source
is either set
to file
or an empty string. If policies.policy_path
is set, then Tyk will load policies
from all the JSON files under the directory specified by the policies.policy_path
option.
In this configuration, Tyk Gateway will allow policy management through the Gateway API.
PortsWhiteList
TYK_GW_PORTWHITELIST
then remember to escape
JSON strings.
bool
string
bool
string
http://dashboard_host:port
int
bool
true
to enable filtering (sharding) of APIs.
[]string
OR
operations.
If you include a non-filter tag (e.g. an identifier such as node-id-1
, this will become available to your Dashboard analytics).
string
redis
(lowercase)
string
localhost
, but for production this should be set to a cluster.
int
[]string
string
string
string
string
int
int
int
int
bool
bool
bool
string
string
string
string
string
bool
autodiscover
the Dashboard through heartbeat messages via Redis.
The goal of zeroconf is auto-discovery, so you do not have to specify the Tyk Dashboard address in your Gatewaytyk.conf
file.
In some specific cases, for example, when the Dashboard is bound to a public domain, not accessible inside an internal network, or similar, disable_dashboard_zeroconf
can be set to true
, in favor of directly specifying a Tyk Dashboard address.
slave_options
allow you to configure the RPC slave connection required for MDCB installations.
These settings must be configured for every RPC slave/worker node.
bool
true
to connect a worker Gateway using RPC.
bool
true
to use an SSL RPC connection.
bool
true
to allow the certificate validation (certificate chain and hostname) to be skipped.
This can be useful if you use a self-signed certificate.
string
string
string
bool
true
to enable RPC caching for keys.
bool
false
(the default setting). For Legacy Cloud Gateways it must be set to ‘true’.
bool
true
if you don’t want to monitor changes in the keys from a primary Gateway.
string
zone
that this instance inhabits, e.g. the cluster/data-center the Gateway lives in.
The group ID must be the same across all the Gateways of a data-center/cluster which are also sharing the same Redis instance.
This ID should also be unique per cluster (otherwise another Gateway cluster can pick up your keyspace events and your cluster will get zero updates).
int
int
int
float32
float32
float32
bool
bool
true
, distributed rate limiter will be disabled for this node, and it will be excluded from any rate limit calculation.
db_app_conf_options.node_is_segmented
to true
for multiple Gateway nodes, you should ensure that management_node
is set to false
.
This is to ensure visibility for the management node across all APIs.management_node
is not a valid configuration option.
Always set management_node
to false
in pro environments.
bool
bool
bool
true
. The sentinel-based rate limiter delivers a smoother performance curve as rate-limit calculations happen off-thread, but a stricter time-out based cool-down for clients. For example, when a throttling action is triggered, they are required to cool-down for the period of the rate limit.
Disabling the sentinel based rate limiter will make rate-limit calculations happen on-thread and therefore offers a staggered cool-down and a smoother rate-limit experience for the client.
For example, you can slow your connection throughput to regain entry into your rate limit. This is more of a “throttle” than a “block”.
The standard rate limiter offers similar performance as the sentinel-based limiter. This is disabled by default.
bool
bool
int
float64
rate_threshold = drl_threshold * number_of_gateways
.
So you have 2 Gateways, and your threshold is set to 5, if a user rate limit is larger than 10, it will use the distributed rate limiter algorithm.
Default: 5
bool
bool
bool
bool
bool
true
to have monitors enabled in your configuration for the node.
string
string
string
map[string]string
int64
float64
bool
bool
int
int
int64
bool
bool
bool
int
bool
bool
uint16
uint16
[]string
float64
bool
bool
true
to force Tyk to close the connection with the server, otherwise the connections will remain open for as long as your OS keeps TCP connections open.
This can cause a file-handler limit to be exceeded. Setting to false can have performance benefits as the connection can be reused.
bool
true
.
string
int
HostUp
or HostDown
event. For example, a setting of 3 will require at least three failures to occur before the uptime test is triggered.
int
int
bool
true
to have the node capture and record analytics data regarding the uptime tests.
bool
true
will enable the health-check endpoint on /Tyk/health.
int64
string
string
int
int64
int32
int32
string
int
bool
true
if you want to see them for debugging reasons.
bool
bool
true
and fill in the sub-section below to enable logging.
string
rpc
for multi-cloud.
[]string
bool
true
to have Tyk store the inbound request and outbound response data in HTTP Wire format as part of the Analytics data.
Please note, this will greatly increase your analytics DB size and can cause performance degradation on analytics processing by the Dashboard.
This setting can be overridden with an organization flag, enabed at an API level, or on individual Key level.
bool
true
and assign a DB using the geo_ip_db_path
setting.
string
bool
true
to enable normalisation.
bool
bool
bool
[]string
{var}
placeholder.
int
uint64
int
bool
true
to have Tyk automatically divide the analytics records in multiple analytics keys.
This is especially useful when storage.enable_cluster
is set to true
since it will distribute the analytic keys across all the cluster nodes.
float32
string
bool
analytics_storage
.
string
redis
(lowercase)
string
localhost
, but for production this should be set to a cluster.
int
[]string
string
string
string
string
int
int
int
int
bool
bool
bool
string
string
string
string
string
time.Duration
bool
true
will enable caching of DNS queries responses used for API endpoint’s host names. By default caching is disabled.
int64
ttl
to -1
prevents record from being expired and removed from cache on next check interval.
string
pick_first
will instruct your Tyk Gateway to connect to the first IP in a returned IP list and cache the response.random
will instruct your Tyk Gateway to connect to a random IP in a returned IP list and cache the response.no_cache
will instruct your Tyk Gateway to connect to the first IP in a returned IP list and fetch each addresses list without caching on each API endpoint DNS query.bool
true
this allows you to disable the regular expression cache. The default setting is false
.
int32
disable_regexp_cache
to false
, you can use this setting to limit how long the regular expression cache is kept for in seconds.
The default is 60 seconds. This must be a positive value. If you set to 0 this uses the default value.
bool
true
to stop Tyk from caching keys locally on the node.
bool
string
redis
(lowercase)
string
localhost
, but for production this should be set to a cluster.
int
[]string
string
string
string
string
int
int
int
int
bool
bool
bool
string
string
string
string
string
bool
string
bundle-latest.zip
specified in the API settings, Tyk will fetch the following URL: http://my-bundle-server.com/bundles/bundle-latest.zip (see the next section for details).
bool
bool
int
bool
string
string
bool
string
int
int
string
bool
dns:///
protocol in coprocess_grpc_server
.
string
string
bool
true
will override any individual API and Ignore, Blacklist and Whitelist plugin endpoint settings.
bool
string
info
.
string
standard
.
bool
[]string
api_key
will include they obfuscated or hashed key.client_ip
will include the ip of the request.host
will include the host of the request.method
will include the request method.path
will include the path of the request.protocol
will include the protocol of the request.remote_addr
will include the remote address of the request.upstream_addr
will include the upstream address (scheme, host and path)upstream_latency
will include the upstream latency of the request.latency_total
will include the total latency of the request.user_agent
will include the user agent of the request.status
will include the response status code.string
bool
map[string]interface{}
bool
string
string
map[string]string
int
string
string
string
bool
bool
string
string
string
string
string
string
float64
bool
string
string
bool
bool
bool
bool
string
string
bool
string
string
bool
string
bool
string
string
bool
string
string
apidef.EventHandlerMetaConfig
bool
bool
bool
int64
struct
string
string
string
string
string
string
string
string
string
string
bool
string
int
map[string]string
TYK_GW_SECRETS=key1:value1,key2:/value2
Produces: {"key1": "value1", "key2": "/value2"}
The secret value may be used as secrets://key1
from the API definition.
In versions before gateway 5.3, only listen_path
and target_url
fields
have had the secrets replaced.
See more details https://tyk.io/docs/tyk-self-managed/#how-to-access-the-externally-stored-data
auth.auth_field_missing
auth.key_not_found
oauth.auth_field_missing
oauth.auth_field_malformed
oauth.key_not_found
oauth.client_deleted
bool
bool
int
int
bool
example
and examples
fields against the declared schemas in the OpenAPI Document. Defaults to false.
bool
default
fields against the declared schemas in the OpenAPI Document. Defaults to false.
bool
[]string