Press enter to see results or esc to cancel.


NGINX Web Server Integration Manual

BotGuard provides the integration module for Nginx web server via operating systems package repository. We support the following operating systems:

  • Debian 10 ("buster"), 9 ("stretch")
  • Ubuntu 20.04 ("focal"), 18.04 ("bionic"), 16.04 ("xenial")
  • RHEL/CentOS 8, 7, 6

The integration procedure depends on the type of operating system used:

Module installation

The version of the BotGuard Nginx extension module must match with the version of Nginx server installed. In addition to the versions from the system repository, which may be outdated, the Nginx assemblies with the current version of the web server from the repository are often used. First of all, you should determine the version of Nginx installed on your system, and from which repository you got it. Depending on this, the installation procedure may differ slightly. Use the following command to get this information*:

apt policy nginx
*We assume you are using the root account (use sudo -s or su - if necessary).

As a result of executing this command, a list of Nginx versions available for installation will be displayed. Version installed at the moment, will be marked with asterisks:

   Installed: 1.14.2-2+deb10u2
   Candidate: 1.14.2-2+deb10u2
   Version table:
      1.18.0-5 90
          90 unstable/main amd64 Packages
  *** 1.14.2-2+deb10u2 500
         500 buster/main amd64 Packages
         100 /var/lib/dpkg/status
      1.14.2-2+deb10u1 500
         500 buster/updates/main amd64 Packages

If the Nginx version source URL contains:

  •, then use the nginx repository
  •, then use the nginx-mainline repository
  •, then use the nginx repository
  •, then use the ondrej-mainline repository
  • Otherwise use the main repository

Import the BotGuard package digital signature key:

apt install curl gpg ca-certificates lsb-release apt-utils whiptail apt-transport-https software-properties-common
curl -fsSL | apt-key add -

Add the BotGuard repository to the system repositories:

add-apt-repository "deb $(lsb_release -cs) main"

Install the BotGuard Nginx extension module:

apt update apt install libnginx-mod-botguard

Make sure the Nginx configuration is ok:

nginx -t

Restart the Nginx service:

service nginx restart

Make sure BotGuard module is loaded successfully:

nginx -T 2>/dev/null | grep

As a result of executing this command, the following text should be displayed:

load_module modules/;

In case the command output is empty (for example when Nginx is installed from, then you need to add the following line at the very beginning of the main Nginx configuration file /etc/nginx/nginx.conf:

load_module modules/;

and restart the Nginx service:

service nginx restart

Setting the parameters of the module

After installation, the module will be disabled, as it requires preliminary configuration for its operation. To configure the module, run the command:

dpkg-reconfigure libnginx-mod-botguard

Using this command, you can configure the parameters necessary for the module to work in interactive mode.

Instead, you can change the settings of the module by editing its configuration file /etc/nginx/conf.d/50-botguard.conf:

  1. Find the line # botguard_primary_server; and remove the "#" character (uncomment the line). Replace with the address of the primary BotGuard server assigned to your web server.
  2. Find the line # botguard_secondary_server; and remove the "#" character (uncomment the line). Replace with the address of the secondary BotGuard server.
  3. To enable BotGuard protection for all the domains, find the line # botguard_check on; and remove the "#" character (uncomment the line).
  4. Reload Nginx config after saving changes:service nginx reload

Diagnostic messages and error messages are logged to the /var/log/nginx/error.log file, depending on Nginx settings.