Configuration

The Wazuh manager API takes its general settings from a configuration file and its security settings from API endpoints. Proper configuration and hardening are essential for production environments to prevent unauthorized access and make sure reliable operation.

Wazuh manager API configuration file

The Wazuh manager API configuration file is located at /var/wazuh-manager/api/configuration/api.yaml on the Wazuh manager. By default, most settings are commented out. To apply a different configuration, uncomment and edit the desired line. The file owner is root:wazuh-manager, with mode 0660. An unknown option or a value of the wrong type stops the Wazuh manager API with error 2000. To check the file before you restart the Wazuh manager, run /var/wazuh-manager/bin/wazuh-manager-apid -t -c /var/wazuh-manager/api/configuration/api.yaml.

The following block is the shipped template of the /var/wazuh-manager/api/configuration/api.yaml configuration file, with every setting commented out. For more information on each of the settings, check the configuration options:

# USE THIS FILE AS A TEMPLATE. UNCOMMENT LINES TO APPLY CUSTOM CONFIGURATION

# host: ['0.0.0.0', '::']
# port: 55000

# Advanced configuration

# https:
#  enabled: yes
#  key: "apid-key.pem"
#  cert: "apid.pem"
#  use_ca: False
#  ca: "root-ca.pem"
#  ssl_ciphers: ""  # Passed to OpenSSL as written (case-sensitive); empty = ECDHE+AESGCM:ECDHE+CHACHA20

# Modify API's intervals (time in seconds)
# intervals:
#   request_timeout: 10

# Logging configuration
# Values for API log level: critical, error, warning, info, debug, debug2 (each level includes the previous levels).
# Values for API log max_size: <value><unit>. Valid units: K (kilobytes), M (megabytes)
# Enabling the API log max_size will disable the time based rotation (on midnight)
# logs:
#  level: "info"
#  format: "plain"
#  max_size:
#    enabled: False
#    size: "1M"

# Cross-origin resource sharing: https://www.starlette.io/middleware/#corsmiddleware
# cors:
#  enabled: no
#  source_route: "*"
#  expose_headers: "*"
#  allow_headers: "*"
#  allow_credentials: no

# Access parameters
# access:
#  max_login_attempts: 50
#  block_time: 300
#  max_request_per_minute: 300
#  max_unauthenticated_request_per_minute: 10

# Drop privileges (Run as wazuh-manager user)
# drop_privileges: yes

# Maximum body size that the API can accept, in bytes (0 -> limitless)
# max_upload_size: 10485760

# Maximum size, in bytes, of the run_as authentication context payload
# (POST /security/user/authenticate/run_as). AD/LDAP/SSO logins with large
# group memberships may need to raise this. Independent of max_upload_size,
# which still bounds the overall request body for every endpoint.
# auth_context_max_payload_size: 65536

# Number of processes dedicated to processing authentication requests.
# authentication_pool_size: 2

# Uploadable Wazuh configuration sections
# upload_configuration:
#   agents:
#     allow_higher_versions:
#       allow: yes
#   indexer:
#     allow: yes

Note

In a Wazuh manager cluster, the Wazuh manager API runs only on the master node. It forwards requests that concern a worker node to that worker. Edit /var/wazuh-manager/api/configuration/api.yaml on the master node, and send every Wazuh manager API request to the master node.

Make sure to restart the Wazuh manager API using the Wazuh manager service after editing the configuration file:

# systemctl restart wazuh-manager

API configuration options

General options

Option

Allowed values

Default value

Description

host

List of IP addresses or hostnames

['0.0.0.0', '::']

IP address or hostname of the Wazuh manager where the Wazuh manager API is running.

port

Any value between 1 and 65535

55000

Port where the Wazuh manager API listens.

drop_privileges

yes, true, no, false

true

Run the wazuh-manager-apid process as the wazuh-manager user.

auth_context_max_payload_size

Any integer from 1024 to 1048576

65536

Maximum size, in bytes, of the authorization context body that POST /security/user/authenticate/run_as accepts. A larger body gets HTTP 413.

max_upload_size

0 (no limit) or any positive integer

10485760

Set the maximum body size that the API can accept, in bytes (0 -> limitless).

authentication_pool_size

Any integer between 1 and 50

2

Number of processes dedicated to processing authentication requests.

intervals

request_timeout

Any non-negative number

10

Set the maximum response time (in seconds) for each API request.

https

enabled

yes, true, no, false

true

Enable or disable SSL (https) in the Wazuh manager API.

key

Any text string

apid-key.pem

Name of the private key. Stored in /etc/wazuh-manager/certs.

cert

Any text string

apid.pem

Name of the certificate. Stored in /etc/wazuh-manager/certs.

use_ca

yes, true, no, false

false

Require a client certificate signed by the ca certificate. The Wazuh dashboard doesn't present a client certificate in Wazuh 5.0. Setting use_ca to true breaks the connection between the Wazuh dashboard and the Wazuh manager API.

ca

Any text string

root-ca.pem

Name of the certificate authority (CA) certificate. Stored in /etc/wazuh-manager/certs.

ssl_ciphers

Any text string

""

OpenSSL cipher list for TLS 1.2. The Wazuh manager API passes it to OpenSSL as written, so keywords are case-sensitive. An empty value allows only ECDHE+AESGCM:ECDHE+CHACHA20. This setting does not affect TLS 1.3 cipher suites.

logs

level

critical, error, warning, info, debug, debug2 (each level includes the previous levels)

info

Set the verbosity level of the Wazuh manager API logs.

format

plain, json or both (plain,json)

plain

Set the format of the Wazuh manager API logs.

max_size

enabled

yes, true, no, false

false

Toggle between time-based and size-based Wazuh manager API log rotation. Enabling this option disables time-based rotation, enabling rotation based on file size instead.

size

Any positive number followed by a valid unit. K/k for kilobytes, M/m for megabytes.

1M

Set the log file size that triggers size-based log rotation. The minimum is 1M. A lower value stops the Wazuh manager API from starting with error 2011.

cors

enabled

yes, true, no, false

false

Enable or disable the use of CORS in the Wazuh manager API.

source_route

Any text string

*

Sources for which the resources are available. For example http://client.example.org.

expose_headers

Any text string

*

Which headers can be exposed as part of the response.

allow_headers

Any text string

*

Which HTTP headers can be used during the actual request.

allow_credentials

yes, true, no, false

false

Tell browsers whether to expose the response to frontend JavaScript or not.

access

max_login_attempts

Any positive integer

50

Maximum number of failed login attempts from an IP address before the Wazuh manager API blocks its login requests. See block_time.

block_time

Any positive integer

300

Time, in seconds, after which the count of failed login attempts from an IP address, and any block on it, are cleared. The period starts at the first counted failed attempt and does not restart with later attempts. An address that reaches max_login_attempts failed attempts is blocked from logging in until then.

max_request_per_minute

0 (no limit) or any positive integer

300

The maximum number of requests allowed per minute from each client address. It applies to all Wazuh manager API endpoints, including authentication requests. A client address that reaches this limit gets HTTP 429 for the rest of the minute, and other addresses are not affected. Unauthenticated and failed requests count against max_unauthenticated_request_per_minute instead, 10 by default. A value of 0 disables this limit.

max_unauthenticated_request_per_minute

0 (no limit) or any positive integer

10

The maximum number of unauthenticated and failed requests allowed per minute from each client address. A client address that reaches this limit gets HTTP 429 for the rest of the minute. A value of 0 disables this limit.

upload_configuration

These options control which sections of wazuh-manager.conf a PUT /cluster/{node_id}/configuration request can change. With indexer.allow set to true, the change also requires the cluster:read_secrets permission. The Wazuh manager API still accepts the upload_configuration.remote_commands and upload_configuration.limits.eps options and the cache section, but they have no effect. The logcollector.remote_commands and wazuh_command.remote_commands internal options of the Wazuh agent control remote commands.

agents

allow_higher_versions

allow

yes, true, no, false

true

Allow uploading configurations that accept higher Wazuh agent versions through the Wazuh manager API. Setting this option to false prevents uploading wazuh-manager.conf files that contain the <allow_higher_versions> section with the yes value inside the auth or remote tags.

indexer

allow

yes, true, no, false

true

Allows uploading an updated indexer configuration section through the Wazuh manager API. Setting this option to false prevents updating the Wazuh indexer configuration when uploading wazuh-manager.conf.

Wazuh manager API security configuration

Security-related settings such as token expiration auth_token_exp_timeout, and RBAC behavior rbac_mode are managed exclusively through the Wazuh manager API, not through a configuration file.

The auth_token_exp_timeout defines the duration in seconds before an authentication token expires and requires renewal. The rbac_mode determines the default behavior of the Role-Based Access Control system. It either permits or denies access to any resource that no policy explicitly covers. Refer to the Role-Based Access Control documentation for more details. In a cluster, the configuration applies to the Wazuh manager API on the master node, the only node that runs it.

For more information on each of the settings, see the security configuration options.

Example security configuration settings

Use the following API endpoints (requires administrator privileges and a valid JWT).

All examples assume you have $TOKEN set from authentication steps. Each PUT or DELETE request to /security/config revokes all JWTs, including the one in $TOKEN. Obtain a new token before you run the next example.

View current settings (GET /security/config)

# curl -k -X GET "https://<WAZUH_MANAGER_IP_ADDRESS>:55000/security/config?pretty=true" \
     -H "Authorization: Bearer $TOKEN"

The command output looks similar to this:

{
   "data": {
      "auth_token_exp_timeout": 900,
      "rbac_mode": "white"
   },
   "error": 0
}

Update settings (PUT /security/config)

  1. For auth_token_exp_timeout: Set the token expiration time in seconds (for example, 1800 for 30 minutes).

  2. For rbac_mode: Choose white (allow only permitted resources, the more secure option) or black (deny only restricted resources).

Example: Update token expiration to 30 minutes

# curl -k -X PUT "https://<WAZUH_MANAGER_IP_ADDRESS>:55000/security/config" \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"auth_token_exp_timeout": 1800}'

The command output looks similar to this:

{"message": "Configuration was successfully updated", "error": 0}

Example: Change RBAC mode to black

# curl -k -X PUT "https://<WAZUH_MANAGER_IP_ADDRESS>:55000/security/config" \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"rbac_mode": "black"}'

The command output looks similar to this:

{"message": "Configuration was successfully updated", "error": 0}

Reset to defaults (DELETE /security/config)

This request resets both settings back to defaults (auth_token_exp_timeout: 900, rbac_mode: white).

# curl -k -X DELETE "https://<WAZUH_MANAGER_IP_ADDRESS>:55000/security/config?pretty=true" \
     -H "Authorization: Bearer $TOKEN"

The command output looks similar to this:

{
   "message": "Configuration was successfully updated",
   "error": 0
}

For security reasons, changing the security configuration revokes all JWTs. You must log in and obtain a new token after the change.

Security configuration options

auth_token_exp_timeout

Allowed values

Default value

Description

An integer of 30 or more

900

Set how many seconds it takes for JWTs to expire.

rbac_mode

Allowed values

Default value

Description

black, white

white

Set the behavior of RBAC. By default, everything is allowed in black mode, while everything is denied in white mode. Choose the rbac_mode that better suits the desired RBAC infrastructure. In black mode, a few policies can deny specific action-resource pairs, while white mode is more secure and requires building from scratch.

Configuration endpoints

The Wazuh manager API has several endpoints that allow querying its current configuration. To modify the general API configuration, edit the /var/wazuh-manager/api/configuration/api.yaml file as detailed in the Wazuh manager API configuration file section.

Get configuration

Modify configuration

Restore configuration

SSL certificate

Note

The installation issues the Wazuh manager API certificate, signed by the Wazuh manager certificate authority (CA) in /etc/wazuh-manager/ca/.

The SSL certificate ensures secure communication between the Wazuh manager API and its clients. The certificate files are in the /etc/wazuh-manager/certs/ directory.

Take the following steps to issue a new certificate for the Wazuh manager API from the Wazuh manager CA:

  1. Move the current key and certificate out of the /etc/wazuh-manager/certs directory. Optionally, set the names that the new certificate must cover in the WAZUH_MANAGER_APID_CERT_SANS variable of /etc/wazuh-manager/local.env. Then run the credential resolver to issue a new pair:

    # cd /etc/wazuh-manager/certs
    # mkdir -p /root/apid-certs-backup
    # mv apid-key.pem apid.pem /root/apid-certs-backup/
    # /var/wazuh-manager/bin/wazuh-manager-resolve-credentials --install
    

    The command issues apid.pem and apid-key.pem from the Wazuh manager CA, with the owner and mode that the Wazuh manager requires.

    To use your own certificate instead, place the key and the certificate, followed by any intermediate certificates, directly in /etc/wazuh-manager/certs. Set their owner to root:wazuh-manager and their mode to 0640, and set https.key and https.cert in api.yaml to the filenames. The certificate must chain to the CA in /etc/wazuh-manager/ca/root-ca.pem, must not be a CA certificate, and must include the hostnames of the Wazuh manager as subject alternative names. Do not protect the key with a passphrase. Run /var/wazuh-manager/bin/wazuh-manager-resolve-credentials --check to validate the files. If any check fails, the Wazuh manager does not start.

  2. Restart the Wazuh manager to load the new certificate:

    # systemctl restart wazuh-manager