mariusv / nginx-badbot-blocker

Block bad, possibly even malicious web crawlers (automated bots) using Nginx
861 stars 140 forks source link

[emerg] zero size shared memory zone "one" #170

Closed Tealk closed 6 years ago

Tealk commented 6 years ago

Hello, i get the following issue if i use nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: [emerg] zero size shared memory zone "one" nginx: configuration file /etc/nginx/nginx.conf test failed

mitchellkrogza commented 6 years ago

Hji @Tealk we only introduce a zone called flood please post the contents of your nginx.conf

Tealk commented 6 years ago

Hi @mitchellkrogza I just followed these instructions https://github.com/mariusv/nginx-badbot-blocker/blob/master/VERSION_2/README.md here my nginx.conf

user www-data;
worker_processes 2;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 1024;
    multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 6;
    types_hash_max_size 2048;
    server_tokens off;
    limit_req_zone $binary_remote_addr zone=flood:50m rate=90r/s;
    limit_conn_zone $binary_remote_addr zone=addr:50m;

    server_names_hash_bucket_size 64;
    server_names_hash_max_size 4096;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log off;
    error_log /var/log/nginx/error.log notice;

    ##
    # Opfen File Cache
    ##

    open_file_cache          max=10000 inactive=5m;
    open_file_cache_valid    2m;
    open_file_cache_min_uses 1;
    open_file_cache_errors   on;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 2;
    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;
#   }
#}
mitchellkrogza commented 6 years ago

Whats in your /etc/nginx/conf.d folder ?

Tealk commented 6 years ago

only the blacklist.conf and default.conf default.conf:


    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}```
mitchellkrogza commented 6 years ago

Just try adding this to your nginx.conf and then doing an nginx -t for me

limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

Tealk commented 6 years ago

i have now set up

    limit_req_zone $binary_remote_addr zone=flood:50m rate=90r/s;
    limit_conn_zone $binary_remote_addr zone=addr:50m;
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

now it works thanks you verry much

mitchellkrogza commented 6 years ago

Perfect 👍

craftogrammer commented 4 years ago

Thanks, it helped me.