
Wazuh is an open-source unified Extended Detection and Response (XDR) and Security Information and Event Management (SIEM) platform. It collects and analyzes logs from multiple log sources to detect known threats and adversary techniques mapped to the MITRE ATT&CK Framework. Wazuh detects and prevents threats across endpoints, containers, networks, servers, and cloud environments in real time.
The Wazuh architecture consists of:
This article explains how to deploy a single-node Wazuh stack consisting of the Wazuh server, indexer, and dashboard on a Linux server with Docker Compose, expose the dashboard over HTTPS with Traefik, and deploy a Wazuh agent.
Before you begin, you need to:
wazuh.example.com). Multiple A records for the same domain can cause TLS certificate validation to fail intermittently.Before any Wazuh container starts, the host needs two changes: docker group membership so Compose commands run without sudo, and a higher kernel memory-map limit, since most Linux distributions default to a value too low for the Wazuh indexer. The Docker Compose configuration itself lives in a separate GitHub repository, pinned to a release tag rather than the default branch.
Membership in the docker group lets your user run the Docker Compose commands in this article without sudo.
Add your user to the docker group to run Docker commands without sudo.
Apply the group change to the current session.
Before deploying Wazuh, the underlying server must allow at least 262144 memory map areas, the value controlled by the kernel parameter vm.max_map_count. Some Linux distributions use a lower default, which is insufficient for the Wazuh indexer to memory map index segments.
Check the default value of memory map areas.
If the output is 262144 or higher, skip the next two steps. Ubuntu 24.04, for example, already defaults to 1048576, and setting 262144 would lower the limit.
If the value is lower than 262144, raise it in your active terminal session.
If you raised the value, make the change persistent across reboots.
Use cat /etc/sysctl.conf to verify that the file ends with vm.max_map_count=262144.
The Wazuh Docker repository on GitHub contains Docker Compose configurations to deploy the Wazuh stack. Clone this repository and check out a specific release tag.
Clone the Wazuh Docker repository and check out the v4.14.7 release.
Check the wazuh-docker releases page for the latest stable release, and replace v4.14.7 with that tag if a newer one is available.
Go into the single-node subdirectory.
Generate the Wazuh self-signed TLS certificates.
The generated certificates allow the Wazuh manager, indexer, and dashboard to authenticate each other and communicate securely over TLS.
Traefik acts as a reverse proxy, routing external traffic to the Wazuh dashboard under a custom domain with a valid HTTPS certificate, while the Wazuh stack continues to use self-signed certificates internally.
To establish a trusted HTTPS connection to the Wazuh dashboard, Traefik must validate the dashboard's self-signed certificate against the Wazuh root Certificate Authority (CA), using a serversTransport that references the certificate.
Create a directory for Traefik certificates in the wazuh-docker/single-node/ directory.
Copy the Wazuh root CA certificate to the traefik/certificates directory.
Move into the traefik directory.
Open a configuration file called dynamic.yml.
Define the serversTransport to trust the Wazuh root CA.
Save and close the file.
The repository's default Compose file publishes the dashboard directly. Replace it with a configuration that places Traefik in front of the dashboard, stores data in host directories, and reads credentials from an environment file.
Navigate to the single-node subdirectory.
Remove the default docker-compose.yml file.
Create the .env file that Docker Compose reads for the Traefik and Wazuh services.
Add the following variables:
Replace:
admin@example.com with a valid email address for Let's Encrypt certificate notifications.
wazuh.example.com with the domain name you configured to point to your server.
INDEXER_PASSWORD and DASHBOARD_PASSWORD with a strong, unique password for the Wazuh indexer users, admin and kibanaserver respectively.
The admin user is used for logging into the Wazuh dashboard, and the kibanaserver user serves as a service account for communication between the Wazuh dashboard and the Wazuh indexer.
API_PASSWORD with a strong, unique password for the Wazuh server API user, wazuh-wui. It must be between 8 and 64 characters and must include uppercase and lowercase letters, numbers, and symbols.
Save and close the file.
Restrict access to the .env file so that only your account can read or modify it.
The .env file contains the credentials for your Wazuh deployment. Do not upload it to a public repository or include its contents in screenshots.
Open a new Docker Compose file with nano.
Add the following configuration:
Save and close the file.
This configuration does the following:
WAZUH_DASHBOARD_DOMAIN.wazuh-transport@file to allow Traefik to validate the Wazuh dashboard's self-signed certificate with the mounted Wazuh root CA certificate.traefik Docker network.443.data/, and Traefik's Let's Encrypt certificate data in the letsencrypt directory.This configuration does not expose the Wazuh indexer on port 9200 or the Wazuh manager API on port 55000 outside the Docker network. It also does not publish syslog port 514/udp because this deployment does not collect syslog messages from an external device or server.
If a specific integration requires access to any of these ports, publish the required port in the docker-compose.yml file and restrict access to trusted IP addresses only.
Create the directories that store the Wazuh data.
The Wazuh manager copies its default configuration into these empty directories on its first start.
Change the ownership of the Wazuh indexer and dashboard directories to UID and GID 1000, the non-root user that both containers run as.
Without this step, the indexer cannot write its data and stops, even though docker compose ps still reports the container as Up.
Open the Wazuh dashboard configuration file.
Replace the default value of the password field with the same value you set for API_PASSWORD in your .env file.
Save and close the file.
Generate a hash for the passwords you assigned to the INDEXER_PASSWORD and DASHBOARD_PASSWORD environment variables. Run the command twice, once for each password.
Enter the corresponding password when prompted, and save the resulting hash string each time.
Open the internal_users.yml configuration file.
Update the default hash for the admin and kibanaserver users with the newly generated hashes.
Replace:
INDEXER_PASSWORD_HASH with the hash generated for the INDEXER_PASSWORD.DASHBOARD_PASSWORD_HASH with the hash generated for the DASHBOARD_PASSWORD.Save and close the file.
The Wazuh indexer loads internal_users.yml into its security index only when it creates that index on the first start. Running securityadmin.sh inside the indexer container after the stack starts applies the password hashes in every case, including later password changes after the security index exists.
Start the stack in detached mode.
The first deployment can take several minutes while Docker downloads images and initializes the manager, indexer, and dashboard.
Confirm that the Traefik and Wazuh containers are running.
Every container shows a status of Up.
View the Wazuh indexer logs to confirm it initialized without errors.
Press Ctrl+C to stop following the logs.
Access the Wazuh indexer container to apply security changes.
Your prompt changes to bash-5.2$ inside the container.
Set the installation and configuration directory variables.
Set the certificate path variables.
Set the Java installation directory.
These variables point the security initialization script (securityadmin.sh) to the correct certificates and Java installation.
Apply the new credentials and environment variables using the securityadmin.sh script.
The output ends with Done with success when the script applies the configuration.
Exit the Wazuh indexer container.
Traefik requests a Let's Encrypt certificate for WAZUH_DASHBOARD_DOMAIN the first time it receives a request over HTTPS, so certificate issuance depends on the domain's DNS already resolving correctly to the server.
Access the Wazuh dashboard via a web browser.
Replace WAZUH_DASHBOARD_DOMAIN with your domain.
Log in using the admin username and the password you set for the INDEXER_PASSWORD environment variable.
Verify that the dashboard loads and displays the overview page.
Deploying a Wazuh agent on the same server that hosts the Wazuh stack lets a single server monitor itself, using the same enrollment flow as a separate endpoint.
Click Deploy new agent on the Wazuh dashboard.
Select your operating system and architecture, such as Linux with DEB amd64.
Enter the same domain you use to access the Wazuh dashboard as the server address, and assign a unique name to the Wazuh agent.
Copy and run the installation and systemctl commands generated by the Wazuh dashboard in your terminal.
Verify that the Wazuh agent is active.
The output shows Active: active (running).
Return to the Wazuh dashboard and click Back to agent list.
Refresh the page. Verify that the Wazuh agent status changes from "Never connected" to Active.
Simulate failed SSH logins to generate an alert. From another machine, connect several times and enter a wrong password at each prompt. The PubkeyAuthentication=no option makes SSH ask for a password even if you normally log in with an SSH key.
Replace USERNAME with your username and SERVER_PUBLIC_IP with your server's public IP address.
Navigate to https://WAZUH_DASHBOARD_DOMAIN/app/threat-hunting#/ and click the Events tab. Replace WAZUH_DASHBOARD_DOMAIN with your domain. Enter rule.groups:authentication_failed in the search bar to show only the failed login alerts.
Verify that alerts for the failed SSH logins appear, including timestamps, descriptions, rule levels, and rule IDs.
You have deployed a single-node Wazuh stack using Docker Compose, exposed the Wazuh dashboard through Traefik with a Let's Encrypt certificate, and enrolled a Wazuh agent that generated and reported a security alert. For more configuration options, refer to the official Wazuh documentation.
0 Comments
Be the first to comment and share your perspective with the community.