-
Notifications
You must be signed in to change notification settings - Fork 295
Add ModSecurity to existing Nginx #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@muzzammilhussain there's no pre-built modules for ModSecurity-nginx. You could try switching to Nginx Plus (aka Nginx WAF) which provides the pre-built module for you in addition to commercial support: https://docs.nginx.com/nginx-waf/admin-guide/nginx-plus-modsecurity-waf-installation-logging/ Alternatively you may also try downloading the same version of Nginx that you're currently running, compiling libModSecurity as per recommended compilation recipes but using the --add-dynamic-module when compiling Nginx with the ModSecurity-nginx connector. That should generate an ELF LSB shared object file (ngx_http_modsecurity_module.so). Then add the load_module statement to your nginx.conf. There's also a tutorial from Nginx here: https://www.nginx.com/blog/compiling-and-installing-modsecurity-for-open-source-nginx/ |
dear @victorhora the basic issue is this error which is coming nginx: [emerg] module "/usr/share/nginx/modules/ngx_http_modsecurity_module.so" is not binary compatible in /etc/nginx/nginx.conf:4 |
nginx version: nginx/1.14.0 |
FWIW I was able to get this working on nginx-1.15.8 (installed via
Nginx configuration options from
Running configure (grabbed source code from http://nginx.org/download/nginx-1.15.8.tar.gz):
Then run Running
|
its work. |
Here does not work: but when I try to configure
|
Thank you for the guide @ejhayes I have one issue which i can't figure out. Although i have now got nginx -t to display the correct message and set everything up according to https://www.nginx.com/blog/compiling-and-installing-modsecurity-for-open-source-nginx/#mainline and your guide above, for some reason when i type nginx -V it doesn't include the modsecurity dynamic module even though i've typed make modules and then copied the so file to /etc/nginx/modules. this is my output: help please! :) thanks |
Hi @SI-BenHodges, What happens when you try to load the module? |
Hey, I can load the module just fine and it does appear to work (so far from what i've tested) but every guide/video i've watched runs the nginx -V command and sees the modsecurity module come up but why does mine not? thanks |
Hi @SI-BenHodges, I believe that the ones listed on -V are the ones statically compiled. The dynamic ones are not listed. |
Hi, I am also trying to install ModSecurity to my current Nginx, i have tried the quoted example but i received the following error after entering
Is anyone able to tell me where did I go wrong? This is the output when i run
|
I'm trying to install ModSecurity on Raspbian. nginx -t nginx: [emerg] module "/usr/share/nginx/modules/ngx_http_modsecurity_module.so" is not binary compatible in /etc/nginx/nginx.conf:3 Ended up googling it and ending on this page. |
Hi @trvrcr, This sounds to be a question more related to Nginx itself than to ModSecurity. Is there any other error message? |
Nginx is working fine when I remove the ModSecurity Module. |
Have you tried to build any other module for Nginx? is it working? |
@zimmerle, |
@zimmerle, |
Hello all, same problem here, same architecture like @trvrcr (raspbian 10), even nginx version used equals to his one. I did compare modsecurity connector build by me with other dynamic modules provided out of the box by nginx deb package and found out that my connector somewhat differs: library built by raspbian devs:file ngx_http_auth_pam_module.so library built by mefile ngx_http_modsecurity_module.so Mine is not stripped and includes debug_info. However, these differences should not cause "...is not binary compatible" errors afaik. to go for sure: same procedure (compiling libmodsecurity connector to nginx without flag "--with-compat" being set) I did try on amd64 architecture using debian 10 buster. Error message displayed by nginx -t stays the same: conclusion: |
This issue is more related to a compilation issue than ModSecurity. Look at the build signature as listed here: Other info that may be relevant:
|
Same problem, unable to compile. make -f objs/Makefile modules |
sudo apt-get install libperl-dev |
hi everyone, i have this problem. nginx -t nginx: [emerg] module "/usr/share/nginx/modules/ngx_http_modsecurity_module.so**" version 1018000 instead of 1021004 in /etc/nginx/nginx.conf:5**
nginx: configuration file /etc/nginx/nginx.conf test failed my configurations /etc/nginx/nginx.conf is cat /etc/nginx/nginx.conf user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
load_module modules/ngx_http_modsecurity_module.so;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
modsecurity on;
modsecurity_rules_file /etc/nginx/modsec/modsec-config.conf;
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
my nginx version is nginx -v nginx version: nginx/1.21.4 |
The same issue nginx -v Anyone solved this problem? |
Hello @olegsidokhmetov , What you are reporting appears to be only superficially similar to the rest of this closed issue's content. libfuzzy is used by a specific, small (and I suspect little-used) portion of ModSecurity's functionality. You haven't provided much information about your environment or your build/installation process, but with on what you have posted, I'll note a few things for you to consider. Based on when and where you are seeing an error, the output from './configure' probably includes:
So:
|
I have tried my Luck but could not find how to add ModSecurity to existing running nginx.
The text was updated successfully, but these errors were encountered: