Installing dynamic Wallarm module for NGINX Plus¶
These instructions describe the steps to install Wallarm filtering node as a dynamic module for the official commercial version of NGINX Plus.
If you deploy several Wallarm nodes
All Wallarm nodes deployed to your environment must be of the same versions. The postanalytics modules installed on separated servers must be of the same versions too.
Before installation of the additional node, please ensure its version matches the version of already deployed modules. If the deployed module version is deprecated or will be deprecated soon (4.0
or lower), upgrade all modules to the latest version.
To check the installed version of filtering node and postanalytics installed on the same server:
apt list wallarm-node
apt list wallarm-node
yum list wallarm-node
To check the versions of filtering node and postanalytics installed on different servers:
# run from the server with installed Wallarm filtering node
apt list wallarm-node-nginx
# run from the server with installed postanalytics
apt list wallarm-node-tarantool
# run from the server with installed Wallarm filtering node
apt list wallarm-node-nginx
# run from the server with installed postanalytics
apt list wallarm-node-tarantool
# run from the server with installed Wallarm filtering node
yum list wallarm-node-nginx
# run from the server with installed postanalytics
yum list wallarm-node-tarantool
Requirements¶
-
Access to the account with the Administrator or Deploy 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
) -
For the request processing and postanalytics on different servers: postanalytics installed on the separate server upon the instructions
-
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:444
for working with US Wallarm Cloud or tohttps://api.wallarm.com:444
for working with EU Wallarm Cloud. If access can be configured only via the proxy server, then use the instructions -
Installed text editor vim, nano, or any other. In the instruction, vim is used
Installation options¶
The processing of requests in the Wallarm node is divided into two stages:
-
Primary processing in the NGINX-Wallarm module. The processing is not memory demanding and can be put on frontend servers without changing the server requirements.
-
Statistical analysis of the processed requests in the postanalytics module. Postanalytics is memory demanding, which may require changes in the server configuration or installation of postanalytics on a separate server.
Depending on the system architecture, the NGINX-Wallarm and postanalytics modules can be installed on the same server or on different servers.
Installation commands for both options are described in the further instructions.
Installation¶
1. Install NGINX Plus and dependencies¶
Install NGINX Plus and its dependencies using these official NGINX instructions.
Installing on Amazon Linux 2.0.2021x and lower
To install NGINX Plus on Amazon Linux 2.0.2021x and lower, use the CentOS 7 instructions.
2. Add Wallarm repositories¶
Wallarm node is installed and updated from the Wallarm repositories. To add repositories, use the commands for your platform:
sudo apt 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/2.18/' | sudo tee /etc/apt/sources.list.d/wallarm.list"
sudo apt update
curl -fsSL https://repo.wallarm.com/wallarm.gpg | sudo apt-key add -
sh -c "echo 'deb https://repo.wallarm.com/ubuntu/wallarm-node xenial/2.18/' | sudo tee /etc/apt/sources.list.d/wallarm.list"
sudo apt update
curl -fsSL https://repo.wallarm.com/wallarm.gpg | sudo apt-key add -
sh -c "echo 'deb https://repo.wallarm.com/ubuntu/wallarm-node bionic/2.18/' | sudo tee /etc/apt/sources.list.d/wallarm.list"
sudo apt update
curl -fsSL https://repo.wallarm.com/wallarm.gpg | sudo apt-key add -
sh -c "echo 'deb https://repo.wallarm.com/ubuntu/wallarm-node focal/2.18/' | 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/2.18/x86_64/Packages/wallarm-node-repo-1-6.el7.noarch.rpm
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -i https://repo.wallarm.com/centos/wallarm-node/7/2.18/x86_64/Packages/wallarm-node-repo-1-6.el7.noarch.rpm
sudo yum install -y epel-release
sudo rpm -i https://repo.wallarm.com/centos/wallarm-node/8/2.18/x86_64/Packages/wallarm-node-repo-1-6.el8.noarch.rpm
3. Install Wallarm packages¶
Request processing and postanalytics on the same server¶
To run postanalytics and process the requests on the same server, the following packages are required:
-
nginx-plus-module-wallarm
for the NGINX Plus-Wallarm module -
wallarm-node
for the postanalytics module, Tarantool database, and additional NGINX Plus-Wallarm packages
sudo apt install --no-install-recommends wallarm-node nginx-plus-module-wallarm
sudo apt install --no-install-recommends wallarm-node nginx-plus-module-wallarm
sudo yum install wallarm-node nginx-plus-module-wallarm
Request processing and postanalytics on different servers¶
To run postanalytics and process the requests on different servers, the following packages are required:
-
wallarm-node-nginx
andnginx-plus-module-wallarm
for the NGINX Plus-Wallarm modulesudo apt install --no-install-recommends wallarm-node-nginx nginx-plus-module-wallarm
sudo apt install --no-install-recommends wallarm-node-nginx nginx-plus-module-wallarm
sudo yum install wallarm-node-nginx nginx-plus-module-wallarm
-
wallarm-node-tarantool
on the separate server for the postanalytics module and Tarantool database (installation steps are described in the instructions)
4. Connect the Wallarm module¶
-
Open the file
/etc/nginx/nginx.conf
:sudo vim /etc/nginx/nginx.conf
-
Add the following directive right after the
worker_processes
directive:load_module modules/ngx_http_wallarm_module.so;
Configuration example with the added directive:
user nginx; worker_processes auto; load_module modules/ngx_http_wallarm_module.so; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid;
-
Copy the configuration files for the system setup:
sudo cp /usr/share/doc/nginx-plus-module-wallarm/examples/*.conf /etc/nginx/conf.d/
5. Connect the filtering node to Wallarm Cloud¶
The Wallarm node interacts with the Wallarm Cloud. To connect the filtering node to the Cloud, proceed with the following steps:
-
Make sure that your Wallarm account has the Administrator or Deploy role enabled and two-factor authentication disabled in Wallarm Console.
You can check mentioned settings by navigating to the users list in the US Cloud or EU Cloud.
-
Run the
addnode
script in a system with the installed Wallarm node:sudo /usr/share/wallarm-common/addnode -H us1.api.wallarm.com
sudo /usr/share/wallarm-common/addnode
-
Input the email and password for your account in Wallarm Console.
-
Input the filtering node name or click Enter to use an automatically generated name.
The specified name can be changed in Wallarm Console → Nodes later.
-
Open the Wallarm Console → Nodes section in the US Cloud or EU Cloud and ensure a new filtering node is added to the list.
6. Update Wallarm node configuration¶
Main configuration files of NGINX and Wallarm filtering node are located in the directories:
-
/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
Request filtration mode¶
By default, the filtering node is in the status off
and does not analyze incoming requests. To enable requests analysis, please follow the steps:
-
Open the file
/etc/nginx/conf.d/default.conf
:sudo vim /etc/nginx/conf.d/default.conf
-
Add the line
wallarm_mode monitoring;
to thehttps
,server
orlocation
block:
Example of the file /etc/nginx/conf.d/default.conf
server {
# port for which requests are filtered
listen 80;
# domain for which requests are filtered
server_name localhost;
# Filtering node mode
wallarm_mode monitoring;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
When operating in the monitoring
mode, the filtering node searches attack signs in requests but does not block detected attacks. We recommend keeping the traffic flowing via the filtering node in the monitoring
mode for several days after the filtering node deployment and only then enable the block
mode. Learn recommendations on the filtering node operation mode setup →
Memory¶
Postanalytics module on the separate server
If you installed the postanalytics module on a separate server, then skip this step as you already have the module configured.
The Wallarm node uses the in-memory storage Tarantool. Learn more about amount of required resources here. Note that for testing environments you can allocate lower resources than for the production ones.
To allocate memory for Tarantool:
-
Open the Tarantool configuration file in the editing mode:
sudo vim /etc/default/wallarm-tarantool
sudo vim /etc/default/wallarm-tarantool
sudo vim /etc/sysconfig/wallarm-tarantool
-
Specify memory size in GB in the
SLAB_ALLOC_ARENA
directive. The value can be an integer or a float (a dot.
is a decimal separator).Detailed recommendations about allocating memory for Tarantool are described in these instructions.
-
To apply changes, restart Tarantool:
sudo systemctl restart wallarm-tarantool
Address of the separate postanalytics server¶
NGINX-Wallarm and postanalytics on the same server
If the NGINX-Wallarm and postanalytics modules are installed on the same server, then skip this step.
Add postanalytics server addresses to the file /etc/nginx/conf.d/wallarm.conf
:
upstream wallarm_tarantool {
server <ip1>:3313 max_fails=0 fail_timeout=0 max_conns=1;
server <ip2>:3313 max_fails=0 fail_timeout=0 max_conns=1;
keepalive 2;
}
# omitted
wallarm_tarantool_upstream wallarm_tarantool;
-
max_conns
value must be specified for each of the upstream Tarantool servers to prevent the creation of excessive connections. -
keepalive
value must not be lower than the number of the Tarantool servers. -
The
# wallarm_tarantool_upstream wallarm_tarantool;
string is commented by default - please delete#
.
Other configurations¶
To update other NGINX and Wallarm node configurations, use the NGINX documentation and the list of available Wallarm node directives.
7. Restart NGINX Plus¶
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 service nginx restart
sudo systemctl restart nginx
8. Test Wallarm node operation¶
-
Send the request with test SQLI and XSS attacks to the protected resource address:
curl http://localhost/?id='or+1=1--a-<script>prompt(1)</script>'
-
Open the Wallarm Console → Events section in the US Cloud or EU Cloud and ensure attacks are displayed in the list.
Settings customization¶
The dynamic Wallarm module with default settings is installed for NGINX Plus. To customize Wallarm node settings, use the available directives.
Common customization options:
-
Using the balancer of the proxy server behind the filtering node
-
Adding Wallarm Scanner addresses to the allowlist in the
block
filtration mode -
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