Core
Guides v2.x
2

Configuring Kuzzle #

The Kuzzle configuration is stored in a kuzzlerc file (opens new window) found in the root folder of your Kuzzle installation.

Kuzzle uses rc (opens new window) to override its default configuration by either:

Use .kuzzlerc file #

You can write your custom config parameters in a .kuzzlerc and store it in $HOME/.kuzzlerc or one of these locations (opens new window):

Copied to clipboard!
{
  "services": {
    "storageEngine": {
      "client": {
        "host": "http://localhost:9200"
      }
    }
  }
}

Use Environment Variables #

The name of the environment variable must match the path of the configuration parameter in the .kuzzlerc file. To set the name of the environment variable:

  • Use the prefix kuzzle_,
  • then append the parameter path (as defined in the .kuzzlerc file) by using a double underscore __ to separate each level of its hierarchy.

For example, the .kuzzlerc parameter services.storageEngine.host in example 1, is represented by the environment variable kuzzle_services__storageEngine__host:

Copied to clipboard!
export kuzzle_services__storageEngine__host="http://localhost:9200"

You can also pass stringified JSON values this way to override non-scalar values such as objects or arrays. To do so, prefix a valid stringified JSON with *json: to instruct Kuzzle to parse the content of the value as JSON.

Examples:

Copied to clipboard!
export kuzzle_security__restrictedProfileIds='*json:["default","foo","bar"]'
export kuzzle_services__common='*json:{"defaultInitTimeout":120000, "retryInterval":1000}'

Docker Compose #

Environment variables are particularly handy when running Kuzzle in a Docker container. Using Docker Compose, they can easily be configured in the environment section of the docker-compose.yml file. For example, here's how we pass environment variables to Kuzzle in our default docker-compose file:

Copied to clipboard!
version: '3'

services:
  kuzzle:
    image: kuzzleio/kuzzle:2
    cap_add:
      - SYS_PTRACE
    depends_on:
      - redis
      - elasticsearch
    environment:
      - kuzzle_services__storageEngine__client__node=http://elasticsearch:9200
      - kuzzle_services__internalCache__node__host=redis
      - kuzzle_services__memoryStorage__node__host=redis
      - NODE_ENV=production

  redis:
    image: redis:6

  elasticsearch:
    image: kuzzleio/elasticsearch:7
    ulimits:
      nofile: 65536

For an exhaustive list of configuration parameters, please refer to the kuzzlerc sample file (opens new window).

Use Backend.config property #

Available since 2.8.0

You can change the configuration only during the setup phase, before starting the application.

The configuration of Kuzzle is also accessible through the Backend.config property.

It is possible to read or edit values of the configuration.

The set of keys that can be configured is available in the file .kuzzlerc.sample.jsonc (opens new window)

See the Configuration guide for more information on how to configure Kuzzle.

Example: Change configuration values

Copied to clipboard!
// Read a configuration value
console.log(`Kuzzle will listen on port ${app.config.content.server.port}`);

// Set log level to verbose
app.config.content.plugins['kuzzle-plugin-logger'].services.stdout.level = 'verbose';

// Listen to port 4242
app.config.content.server.port = 4242;