Git Product home page Git Product logo

rate-limit-nginx-module's People

Contributors

kleisauke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rate-limit-nginx-module's Issues

TIME_WAIT

The connections with redis will remain in TIME_WAIT state for a period of time (I think 1 - 4 minute). If you log 10.000 / minute you will have aprox 10.000 connection in time_wait state.

Tag a release

Since it is production-ready, can you please tag a release version here, e.g. 1.0.0?

Rate limit based on API Key tier

Hi, I am trying this module to work with API key based rate limiting. We want to implement rate limit on API key based on tier. Some API key required to have 50 RPS and Some required to have 100 RPS. Our implementation of rate limiting is below.

map $ms_apikey $ratelimit_tier10000 {
        include /etc/nginx/ratelimit_tier10000.map;
        default '';
    }

    map $ms_apikey $ratelimit_tier1000 {
        include /etc/nginx/ratelimit_tier1000.map;
        default '';
    }

    map $ms_apikey $ratelimit_tier500 {
        include /etc/nginx/ratelimit_tier500.map;
        default '';
    }

    map $ms_apikey $ratelimit_tier200 {
        include /etc/nginx/ratelimit_tier200.map;
        default '';
    }

    map $ms_apikey $ratelimit_tier100 {
        include /etc/nginx/ratelimit_tier100.map;
        default '';
    }

    map $ms_apikey $ratelimit_tier50 {
        include /etc/nginx/ratelimit_tier50.map;
        default '';
    }

    map $ratelimit_tier10000$ratelimit_tier1000$ratelimit_tier500$ratelimit_tier50$ratelimit_tier200$ratelimit_tier100 $ratelimit_default {
        ''   $ms_apikey;
        default '';
    }

Here we store API keys on file based on their tiers and map it in nginx.conf file. This mapping works well with default rate limiting module. Implementation on location block like below.

location /somepath {
        rate_limit $ratelimit_default requests=5 period=1s burst=5;
        rate_limit $ratelimit_tier50 requests=50 period=1s burst=50;
        rate_limit $ratelimit_tier100 requests=100 period=1s burst=110;
        rate_limit_pass redis;
        proxy_pass http://www.example.com;
    }

I have stored API key in /etc/nginx/ratelimit_tier50.map file so API key should have 50 RPS rate limit. While running load test with 150 RPS it isn't blocking nor i see any movement on redis. Please guide if i am doing something wrong in implementation.

cluster sync

Is there a way to use this to sync rate limits on multiple load balancer servers in cluster?

Module is not installing

I am trying to install this module in existing nginx. Followed the steps and tried configuring using below command.

./configure --with-compat --add-dynamic-module=rate-limit-nginx-module --prefix=/etc/nginx

Module ngx_http_rate_limit_module.so is getting installed in /etc/nginx/modules but when i add directive rate_limit_pass redis; it is giving below error.

nginx: [emerg] unknown directive "rate_limit_pass" in /etc/nginx/conf.d/file.conf:28

Tried loading module in nginx.conf load_module modules/ngx_http_rate_limit_module.so;

nginx: [emerg] module "/etc/nginx/modules/ngx_http_rate_limit_module.so" is not binary compatible in /etc/nginx/nginx.conf:3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.