throttle nginx bandwidth per website

i would like to limit website's bandwidth using Nginx in order to share it among multiple websites like i'm able to do in IIS7.

From reading the doc, i found i need to use

limit_req_zone inside http { },

but then, all example are made to limit request rate and not bandwidth, they use $binary_remote_addr, i guess I should use $host instead,

zone=NAME:value , this part is okay.

example uses "rate=value" at the end, but i don't want to limit the connection rate for the website, i want to limit the bandwidth, could i replace it with limit_rate=value ?

Once the zone is setup, i guess i only need to use limit_req at the right place.


Solution 1:

You can either user the limit_rate directive or set the $limit_rate variable in the right contexts (cf. docs).

Here is an example with the variable:

http {
    map $host $limit_rate {
        example.org 0;
        example.com 1m;
        default 4k;
    }

    server {
        listen 80;
    }