Kong Configuration File

Kong Gateway comes with a default configuration file kong.conf. If you installed Kong Gateway using an official package, this file can be found at: /etc/kong/kong.conf.default. The Kong Gateway configuration file is a YAML file that can be used to configure individual properties of your Kong instance. This guide will explain how to configure Kong Gateway using the kong.conf file.

Configure Kong Gateway

To configure Kong Gateway, make a copy of the default configuration file:

  1. cp /etc/kong/kong.conf.default /etc/kong/kong.conf

The file contains configuration properties and documentation:

  1. #upstream_keepalive_pool_size = 60 # Sets the default size of the upstream
  2. # keepalive connection pools.
  3. # Upstream keepalive connection pools
  4. # are segmented by the `dst ip/dst
  5. # port/SNI` attributes of a connection.
  6. # A value of `0` will disable upstream
  7. # keepalive connections by default, forcing
  8. # each upstream request to open a new
  9. # connection.

To configure a property, uncomment it and modify the value:

  1. upstream_keepalive_pool_size = 40

Boolean values can be specified as on/off or true/false:

  1. #dns_no_sync = off # If enabled, then upon a cache-miss every
  2. # request will trigger its own dns query.
  3. # When disabled multiple requests for the
  4. # same name/type will be synchronised to a
  5. # single query.

Kong Gateway will use the default settings for any value in kong.conf that is commented out.

Verify configuration

To verify that your configuration is usable, use the check command. The check command will evaluate the environment variables you have currently set, and will output an error if your settings are invalid.

  1. kong check /etc/kong/kong.conf

If your configuration is valid the shell will output:

  1. configuration at /etc/kong/kong.conf is valid

Set custom path

By default, Kong Gateway looks for kong.conf in two default locations:

  1. /etc/kong/kong.conf
  2. /etc/kong.conf

You can override this behavior by specifying a custom path for your configuration file using the -c / --conf argument in the CLI:

  1. kong start --conf /path/to/kong.conf

Debug mode

You can use the Kong Gateway CLI in debug-mode to output configuration properties in the shell:

  1. kong start -c /etc/kong.conf --vv
  2. 2016/08/11 14:53:36 [verbose] no config file found at /etc/kong.conf
  3. 2016/08/11 14:53:36 [verbose] no config file found at /etc/kong/kong.conf
  4. 2016/08/11 14:53:36 [debug] admin_listen = "0.0.0.0:8001"
  5. 2016/08/11 14:53:36 [debug] database = "postgres"
  6. 2016/08/11 14:53:36 [debug] log_level = "notice"
  7. [...]

More Information