Get the most out of your Centmin Mod LEMP stack
Become a Member

Nginx adding limit_req_zone question

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by hitman, Nov 28, 2015.

  1. hitman

    hitman Member

    117
    10
    18
    Jul 18, 2014
    Ratings:
    +14
    Local Time:
    5:10 AM
    hello
    i am trying to add this
    Module ngx_http_limit_req_module
    i have added
    "limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;"
    in /usr/local/nginx/conf/nginx.conf
    but when i restart nginx i keep getting error
    nginx: [emerg] invalid number of arguments in "limit_req_zone" directive in /usr/local/nginx/conf/nginx.conf:27

    what am i doing wrong??
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,956
    6,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,418
    Local Time:
    1:10 PM
    Nginx 1.13.x
    MariaDB 5.5
    post contents of /usr/local/nginx/conf/nginx.conf in CODE tags
     
  3. hitman

    hitman Member

    117
    10
    18
    Jul 18, 2014
    Ratings:
    +14
    Local Time:
    5:10 AM
    Code:
    user  nginx nginx;
    worker_processes 1;
    worker_priority -10;
    
    worker_rlimit_nofile 260000;
    timer_resolution 100ms;
    
    error_log  logs/error.log;
    
    pid  logs/nginx.pid;
    pcre_jit on;
    
    events {
      worker_connections  2048;
      accept_mutex on;
      accept_mutex_delay 100ms;
      use epoll;
    }
    
    http {
    include /usr/local/nginx/conf/pagespeedadmin.conf;
    include /usr/local/nginx/conf/fastcgi_param_https_map.conf;
    limit_req_zone $binary_remote_addr zone=one:10m rate =1r/s;
    
    
    
    log_format  main  '$remote_addr - $remote_user [$time_local] $request '
      '"$status" $body_bytes_sent "$http_referer" '
      '"$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"'
      ' "$connection" "$connection_requests" "$request_time"';
    
    access_log logs/access.log combined buffer=32k;
    
      index  index.php index.html index.htm;
      include  mime.types;
      default_type  application/octet-stream;
      charset utf-8;
    
      sendfile on;
      #sendfile_max_chunk 1m;
      tcp_nopush  on;
      tcp_nodelay off;
      server_tokens off;
      server_name_in_redirect off;
       
      keepalive_timeout  10;
      keepalive_requests 100;
      lingering_time 20s;
      lingering_timeout 5s;
      keepalive_disable msie6;
    
       gzip on;
       gzip_vary  on;
       gzip_disable "MSIE [1-6]\.";
      gzip_static on;
      gzip_min_length  1400;
      gzip_buffers  32 8k;
      gzip_http_version 1.0;
      gzip_comp_level 5;
      gzip_proxied  any;
      gzip_types text/plain text/css text/xml application/javascript application/x-javascript application/xml application/xml+rss application/ecmascript application/json image/svg+xml;
    
     client_body_buffer_size 256k;
     client_body_in_file_only off;
     client_body_timeout 60s;
     client_header_buffer_size 64k;
    ## how long a connection has to complete sending
    ## it's headers for request to be processed
     client_header_timeout  20s;
     client_max_body_size 10m;
     connection_pool_size  512;
     directio  4m;
     ignore_invalid_headers on;   
     large_client_header_buffers 8 64k;
     output_buffers  8 256k;
     postpone_output  1460;
     proxy_temp_path  /tmp/nginx_proxy/;
     request_pool_size  32k;
     reset_timedout_connection on;
     send_timeout  60s;
     types_hash_max_size 2048;
     server_names_hash_bucket_size 64;
    
    # for nginx proxy backends to prevent redirects to backend port
    # port_in_redirect off;
    
    open_file_cache max=10000 inactive=30s;
    open_file_cache_valid 120s;
    open_file_cache_min_uses 2;
    open_file_cache_errors off;
    open_log_file_cache max=4096 inactive=30s min_uses=2;
    
    ## limit number of concurrency connections per ip to 16
    ## add to your server {} section the next line
    ## limit_conn limit_per_ip 16;
    ## uncomment below line allows 500K sessions
    # limit_conn_log_level error;
    #######################################
    # use limit_zone for Nginx <v1.1.7 and lower
    # limit_zone $binary_remote_addr zone=limit_per_ip:16m;
    #######################################
    # use limit_conn_zone for Nginx >v1.1.8 and higher
     limit_conn_zone $binary_remote_addr zone=limit_per_ip:16m;
    #######################################
    
     include /usr/local/nginx/conf/conf.d/*.conf;
    }
    
     
  4. eva2000

    eva2000 Administrator Staff Member

    30,956
    6,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,418
    Local Time:
    1:10 PM
    Nginx 1.13.x
    MariaDB 5.5
    space between rate =1r/s
     
    • Like Like x 1
    • Informative Informative x 1