Installing Wallarm OOB Dynamic Module for Distribution-Provided NGINX¶
These instructions describe the steps to install Wallarm as an OOB dynamic module using Linux packages for distribution-provided NGINX.
NGINX Open Source can be obtained from nginx.org or the default repositories of Debian/CentOS depending on your requirements, NGINX version preferences, and repository management policies. Wallarm provides packages for both nginx.org and distribution‑provided versions. This guide focuses on NGINX from Debian/CentOS repositories.
The Wallarm module is compatible with distribution-provided NGINX on the following operating systems:
-
Debian 10.x (buster)
-
Debian 11.x (bullseye)
-
CentOS 7.x
-
AlmaLinux, Rocky Linux or Oracle Linux 8.x
Use cases¶
Among all supported Wallarm deployment options, DEB/RPM packages for distribution-provided NGINX is recommended for Wallarm deployment in these use cases:
-
Your infrastructure is based on bare metal or virtual machines without using container-based methods. Typically, these setups are managed with Infrastructure as Code (IaC) tools like Ansible or SaltStack.
-
Your services are built around distribution-provided NGINX. Wallarm can extend its functionalities using these packages.
Requirements¶
-
Access to the account with the Administrator role and two‑factor authentication disabled in Wallarm Console for the US Cloud or EU Cloud
-
SELinux disabled or configured upon the instructions
-
Executing all commands as a superuser (e.g.
root
) -
Access to
https://repo.wallarm.com
to download packages. Ensure the access is not blocked by a firewall -
Access to
https://us1.api.wallarm.com
for working with US Wallarm Cloud or tohttps://api.wallarm.com
for working with EU Wallarm Cloud. If access can be configured only via the proxy server, then use the instructions -
Access to the IP addresses of Google Cloud Storage listed within the link. When you allowlist, denylist, or graylist entire countries, regions, or data centers instead of individual IP addresses, the Wallarm node retrieves precise IP addresses related to the entries in the IP lists from the aggregated database hosted on Google Storage
-
Installed text editor vim, nano, or any other. In the instruction, vim is used
1. Add Debian/CentOS repositories¶
sudo apt -y install dirmngr
curl -fsSL https://repo.wallarm.com/wallarm.gpg | sudo apt-key add -
sh -c "echo 'deb https://repo.wallarm.com/debian/wallarm-node buster/4.6/' | sudo tee /etc/apt/sources.list.d/wallarm.list"
sudo apt update
sudo apt -y install dirmngr
curl -fSsL https://repo.wallarm.com/wallarm.gpg | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/wallarm.gpg --import
sudo chmod 644 /etc/apt/trusted.gpg.d/wallarm.gpg
sh -c "echo 'deb https://repo.wallarm.com/debian/wallarm-node bullseye/4.6/' | sudo tee /etc/apt/sources.list.d/wallarm.list"
sudo apt update
sudo yum install -y epel-release
sudo rpm -i https://repo.wallarm.com/centos/wallarm-node/7/4.6/x86_64/wallarm-node-repo-4.6-0.el7.noarch.rpm
sudo yum install -y epel-release
sudo rpm -i https://repo.wallarm.com/centos/wallarm-node/8/4.6/x86_64/wallarm-node-repo-4.6-0.el8.noarch.rpm
2. Install NGINX with Wallarm packages¶
The command installs the following packages:
-
nginx
for NGINX -
libnginx-mod-http-wallarm
ornginx-mod-http-wallarm
for the NGINX-Wallarm module -
wallarm-node
for the postanalytics module, Tarantool database, and additional NGINX-Wallarm packages
sudo apt -y install --no-install-recommends nginx wallarm-node libnginx-mod-http-wallarm
sudo apt -y install --no-install-recommends nginx wallarm-node libnginx-mod-http-wallarm
sudo yum install -y nginx wallarm-node nginx-mod-http-wallarm
sudo yum install -y nginx wallarm-node nginx-mod-http-wallarm
3. Connect the Wallarm module¶
Copy the configuration files for the system setup:
sudo cp /usr/share/doc/libnginx-mod-http-wallarm/examples/*conf /etc/nginx/conf.d/
sudo cp /usr/share/doc/nginx-mod-http-wallarm/examples/*conf /etc/nginx/conf.d/
sudo cp /usr/share/doc/nginx-mod-http-wallarm/examples/*conf /etc/nginx/conf.d/
4. Connect the filtering node to Wallarm Cloud¶
The Wallarm filtering node interacts with the Wallarm Cloud. You need to connect the node to the Cloud.
When connecting node to the Cloud, you can set the node name, under which it will be displayed in the Wallarm Console UI and put the node into the appropriate node group (used to logically organize nodes in UI).
To connect the node to the Cloud, use a Wallarm token of the appropriate type:
- Open Wallarm Console → Settings → API tokens in the US Cloud or EU Cloud.
- Find or create API token with the
Deploy
source role. - Copy this token.
-
Run the
register-node
script on a machine where you install the filtering node:sudo /usr/share/wallarm-common/register-node -t <TOKEN> --labels 'group=<GROUP>' -H us1.api.wallarm.com
sudo /usr/share/wallarm-common/register-node -t <TOKEN> --labels 'group=<GROUP>'
<TOKEN>
is the copied value of the API token with theDeploy
role.--labels 'group=<GROUP>'
parameter puts your node to the<GROUP>
node group (existing, or, if does not exist, it will be created). If you are installing filtering and postanalytics modules separately, it is recommended to put them into the same group.
- Open Wallarm Console → Nodes in the US Cloud or EU Cloud.
- Do one of the following:
- Create the node of the Wallarm node type and copy the generated token.
- Use existing node group - copy token using node's menu → Copy token.
-
Run the
register-node
script on a machine where you install the filtering node:sudo /usr/share/wallarm-common/register-node -t <TOKEN> -H us1.api.wallarm.com
sudo /usr/share/wallarm-common/register-node -t <TOKEN>
<TOKEN>
is the copied value of the node token. If you are installing filtering and postanalytics modules separately, it is recommended to put them into the same group using the same node token.
- You may add
-n <HOST_NAME>
parameter to set a custom name for your node instance. Final instance name will be:HOST_NAME_NodeUUID
.
5. Enable Wallarm to analyze the traffic¶
By default, the deployed Wallarm node does not analyze incoming traffic.
Perform the following configuration in the /etc/nginx/conf.d/default.conf
file on the machine with the installed node to configure Wallarm to process the traffic mirror:
-
For the Wallarm node to accept mirrored traffic, set the following configuration in the
server
NGINX block:wallarm_force server_addr $http_x_server_addr; wallarm_force server_port $http_x_server_port; # Change 222.222.222.22 to the address of the mirroring server set_real_ip_from 222.222.222.22; real_ip_header X-Forwarded-For; real_ip_recursive on; wallarm_force response_status 0; wallarm_force response_time 0; wallarm_force response_size 0;
- The
set_real_ip_from
andreal_ip_header
directives are required to have Wallarm Console display the IP addresses of the attackers. - The
wallarm_force_response_*
directives are required to disable analysis of all requests except for copies received from the mirrored traffic.
- The
-
For the Wallarm node to analyze the mirrored traffic, set the
wallarm_mode
directive tomonitoring
:server { listen 80; listen [::]:80 ipv6only=on; wallarm_mode monitoring; ... }
Since malicious requests cannot be blocked, the only mode Wallarm accepts is monitoring. For in-line deployment, there are also safe blocking and blocking modes but even if you set the
wallarm_mode
directive to a value different from monitoring, the node continues to monitor traffic and only record malicious traffic (aside from the mode set to off).
6. Restart NGINX¶
Providing user with root
permission
If you are running NGINX as a user that does not have root
permission, then add this user to the wallarm
group using the following command:
usermod -aG wallarm <user_name>;
where <user_name>
is the name of the user without root
permission.
sudo systemctl restart nginx
sudo systemctl restart nginx
sudo systemctl restart nginx
7. Configure sending traffic to the Wallarm instance¶
Configure your environment to mirror incoming traffic to an instance with the Wallarm node you are deploying. For configuration details, we recommend to refer to documentation on the solution you are going to use to produce the traffic mirror (web server, proxy server, etc.).
Inside the link, you will find the example configuration for NGINX, Traefik, Envoy.
8. Test Wallarm node operation¶
-
Send the request with test Path Traversal attack to a protected resource address:
curl http://localhost/etc/passwd
-
Open Wallarm Console → Events section in the US Cloud or EU Cloud and make sure the attack is displayed in the list.
9. Fine-tune the deployed solution¶
The dynamic Wallarm module with default settings is installed for NGINX stable
. The filtering node may require some additional configuration after deployment.
Wallarm settings are defined using the NGINX directives or the Wallarm Console UI. Directives should be set in the following files on the machine with the Wallarm node:
-
/etc/nginx/conf.d/default.conf
with NGINX settings -
/etc/nginx/conf.d/wallarm.conf
with global filtering node settingsThe file is used for settings applied to all domains. To apply different settings to different domain groups, use the file
default.conf
or create new configuration files for each domain group (for example,example.com.conf
andtest.com.conf
). More detailed information about NGINX configuration files is available in the official NGINX documentation. -
/etc/nginx/conf.d/wallarm-status.conf
with Wallarm node monitoring settings. Detailed description is available within the link -
/etc/default/wallarm-tarantool
or/etc/sysconfig/wallarm-tarantool
with the Tarantool database settings
Below there are a few of the typical settings that you can apply if needed:
-
Using the balancer of the proxy server behind the filtering node
-
Limiting the single request processing time in the directive
wallarm_process_time_limit
-
Limiting the server reply waiting time in the NGINX directive
proxy_read_timeout
-
Limiting the maximum request size in the NGINX directive
client_max_body_size