Hi all
I'm new to FreeBSD, nginx and naxsi. I try to use the OS and the two applications to create a simple web application firewall to better protect a couple of websites i run. I have problems including the naxsi ruleset in nginx. Here is step-by-step what i try to do and where i face the problem. I hope a senior FreeBSD-guy can understand what my problem is.
I installed FreeBSD13
Then i installed nginx-naxsi by using
I created the nginx proxy configuration as i wish to have it but without naxsi security enabled. Works well so far. As a last step I try to include the naxsi_core.rules in /usr/local/etc/nginx/nginx.conf to enable the naxsi-rules.
Afterwards, when i try to restart the nginx service, i get the error below:
Googling around for the error brings up this page. The statement is:
Any ideas around what i'm doing wrong?
Do i have to re-compile nginx somehow to include naxsi support? If yes, how do i have to do that?
Best regards
Tom
I'm new to FreeBSD, nginx and naxsi. I try to use the OS and the two applications to create a simple web application firewall to better protect a couple of websites i run. I have problems including the naxsi ruleset in nginx. Here is step-by-step what i try to do and where i face the problem. I hope a senior FreeBSD-guy can understand what my problem is.
I installed FreeBSD13
Code:
root@shield:~ # cat /etc/os-release
NAME=FreeBSD
VERSION=13.0-RELEASE
VERSION_ID=13.0
ID=freebsd
ANSI_COLOR="0;31"
PRETTY_NAME="FreeBSD 13.0-RELEASE"
CPE_NAME=cpe:/o:freebsd:freebsd:13.0
HOME_URL=[URL]https://FreeBSD.org/[/URL]
BUG_REPORT_URL=[URL='https://bugs.FreeBSD.org/']https://bugs.FreeBSD.org/[/URL]
Then i installed nginx-naxsi by using
pkg install nginx-naxsi
. See the nginx details below.
Code:
root@shield:~ # nginx -V
nginx version: nginx/1.20.1
built with OpenSSL 1.1.1k-freebsd 24 Aug 2021 (running with OpenSSL 1.1.1k-freebsd 25 Mar 2021)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt='-I /usr/local/include' --with-ld-opt='-L /usr/local/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx/error.log --user=www --group=www --with-compat --modules-path=/usr/local/libexec/nginx --with-file-aio --http-client-body-temp-path=/var/tmp/nginx/client_body_temp --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp --http-proxy-temp-path=/var/tmp/nginx/proxy_temp --http-scgi-temp-path=/var/tmp/nginx/scgi_temp --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp --http-log-path=/var/log/nginx/access.log --with-http_v2_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-pcre --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --without-mail_imap_module --without-mail_pop3_module --without-mail_smtp_module --with-mail_ssl_module --with-stream_ssl_module --with-threads --with-mail=dynamic --with-stream=dynamic --add-dynamic-module=/wrkdirs/usr/ports/www/nginx-naxsi/work/naxsi-1.3/naxsi_src
I created the nginx proxy configuration as i wish to have it but without naxsi security enabled. Works well so far. As a last step I try to include the naxsi_core.rules in /usr/local/etc/nginx/nginx.conf to enable the naxsi-rules.
Code:
http {
(..)
include naxsi_core.rules;
(..)
server {
(..)
}
}
Afterwards, when i try to restart the nginx service, i get the error below:
Code:
root@shield:~ # service nginx restart
Performing sanity check on nginx configuration:
nginx: [emerg] unknown directive "MainRule" in /usr/local/etc/nginx/naxsi_core.rules:23
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed
Googling around for the error brings up this page. The statement is:
andnginx: [emerg] unknown directive "MainRule" in /etc/nginx/naxsi_core.rules:13. This means that you didn't compiled nginx with naxsi
The only reasonable reason I see would be that nginx is not compiled with Naxsi support. Are you sure it is?
Any ideas around what i'm doing wrong?
Do i have to re-compile nginx somehow to include naxsi support? If yes, how do i have to do that?
Best regards
Tom