Join the community today
Register Now

Nginx Limit connections edit in block?

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by pamamolf, Nov 8, 2014.

  1. pamamolf

    pamamolf Well-Known Member

    2,521
    231
    63
    May 31, 2014
    Ratings:
    +394
    Local Time:
    2:02 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Hi

    I just add this to the global nginx.conf file:
    Code:
    limit_conn_zone $binary_remote_addr zone=alpha:8m;
    and now i want to ad this to the domain config under the server {
    Code:
    limit_conn alpha 5;
    But on this file i have two blocks starting with server { :(
    On which one i must add it?

    Code:
    server {
      listen  80;
      server_name mydomain.com;
      return 301 $scheme://www.mydomain.com$request_uri;
      }
    
    server {
      server_name www.mydomain.com;
    
    Thanks
     
  2. eva2000

    eva2000 Administrator Staff Member

    29,016
    6,585
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,775
    Local Time:
    9:02 AM
    Nginx 1.13.x
    MariaDB 5.5
  3. pamamolf

    pamamolf Well-Known Member

    2,521
    231
    63
    May 31, 2014
    Ratings:
    +394
    Local Time:
    2:02 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    My main problem is that when i try siege from another server and hit my server it is going very slow and i want to limit the requests so i can get an error or wait status after x connections :(

    So i can avoid others do this to my server ...

    Is this ok what i try to do for this scenario?
     
  4. eva2000

    eva2000 Administrator Staff Member

    29,016
    6,585
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,775
    Local Time:
    9:02 AM
    Nginx 1.13.x
    MariaDB 5.5
    trial and error testing ;)
     
  5. pamamolf

    pamamolf Well-Known Member

    2,521
    231
    63
    May 31, 2014
    Ratings:
    +394
    Local Time:
    2:02 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Ok i add it and test it but it is slow again.... :( and server load in 5 minutes goes up to 18 :(

    values that i use:

    main config:
    Code:
    http {
    ...
    limit_conn_zone $binary_remote_addr zone=alpha:8m;
    limit_req_zone $binary_remote_addr zone=delta:8m rate=80r/s;
    ...
    
    Domain config:
    Code:
    server {
    ...
    limit_conn alpha 15;
    limit_req zone=delta burst=100 nodelay;
    ...
    
    Is there any other way?
     
    Last edited: Nov 8, 2014