• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Issue Modsecurity works with Apache but error with nginx

Jürgen_T

Regular Pleskian
Server operating system version
Ubuntu 22.04.5 LTS
Plesk version and microupdate number
Plesk Obsidian v18.0.66_build1800241218.14
I just started to give modsecurity a second try but got this after re-installed it with plesk-installer. Starting with the configuration Nginx (Modsecurity 3.0) I get the following error:

modsecurity_ctl failed: START nginx_modules_ctl --no-restart --enable modsecuritynginx: [emerg] unknown directive "modsecurity" in /etc/nginx/conf.d/modsecurity.conf:5nginx: configuration file /etc/nginx/nginx.conf test failedNginx configuration after enable of 'modsecurity' is in invalid state, rollback the change
Der aktuelle ModSecurity Regelsatz kann nicht verwendet werden und die vorherige Version kann nicht wiederhergestellt werden, da beide ungültige Regeln enthalten.

Changing the configuration from Nginx (Modsecurity 3.0) to Apache (Modesecurity 2.9) it starts without error message.

Any idea how to get it work with Nginx? Did the recent update of Nginx ( nginx/1.26.2) come without modsecurity build?
 
Hi Sebahat, here is the result:
ls -alh /usr/share/nginx/modules =>
total 14M
drwxr-xr-x 2 root root 4.0K Dec 19 20:11 .
drwxr-xr-x 3 root root 4.0K Jun 28 2023 ..
-rw-r--r-- 1 root root 760K Dec 18 15:51 ngx_http_brotli_filter_module.so
-rw-r--r-- 1 root root 15K Dec 18 15:51 ngx_http_brotli_static_module.so
-rw-r--r-- 1 root root 19K Dec 18 15:51 ngx_http_geoip2_module.so
-rw-r--r-- 1 root root 28K Dec 18 15:51 ngx_http_modsecurity_module.so
-rw-r--r-- 1 root root 1.6M Dec 18 15:51 ngx_http_passenger_module.so
-rw-r--r-- 1 root root 12M Dec 18 15:51 ngx_pagespeed.so

The issue is not gone unfortunately:-(
 
Thank you. Could you please try regenerating the web server configuration:

plesk repair web -y

If that doesn't work, I am, unfortunately, out of guesses and it might be best to directly get in touch with our support team.
 
I repaired it now by myself.
To help others here is a step-by-step-approach:
1. ls -alh /etc/nginx/modsecurity.d/rules/owasp_modsecurity_crs_4-plesk/ => No rules have been installed.
2. nginx -V 2>&1 | grep -o with-http_modsecurity_module => no module installed also available
3. /etc/nginx/conf.d/ => no modsecurity.conf available
Solution
wget https://github.com/coreruleset/coreruleset/archive/refs/tags/v4.0.0.tar.gz -O owasp-modsecurity-crs.tar.gz
tar -xzvf owasp-modsecurity-crs.tar.gz -C /etc/nginx/modsecurity.d/rules/
mv /etc/nginx/modsecurity.d/rules/coreruleset-4.0.0 /etc/nginx/modsecurity.d/rules/owasp_modsecurity_crs_4-plesk
modsecurity_rules_file /etc/nginx/modsecurity.d/rules/owasp_modsecurity_crs_4-plesk/crs-setup.conf;
mv crs-setup.conf.example crs-setup.conf
Include /etc/nginx/modsecurity.d/rules/owasp_modsecurity_crs_4-plesk/rules/*.conf;
ningx -t
chmod -R 755 /etc/nginx/modsecurity.d/rules/owasp_modsecurity_crs_4-plesk
chown -R root:root /etc/nginx/modsecurity.d/rules/owasp_modsecurity_crs_4-plesk
systemctl restart nginx
=> Plesk UI => selecht nginx (Modsecurity 3.0) + owasp
=> worked.
Hope, this helps others with similar problems
 
nginx: [emerg] unknown directive "modsecurity" in /etc/nginx/conf.d/modsecurity.conf:5
The error is encountered when the ngx_http_modsecurity_module.so is not loaded.
It's defined in /etc/nginx/modules.conf.d/modsecurity.conf and loaded from /etc/nginx/nginx.conf

NGINX:
include /etc/nginx/modules.conf.d/*.conf;
Around line 11, before the http { block
 
Back
Top