Nginx – limiting bandwidth usage per server block

bandwidthnginx

In Apache we have some great solutions for limiting the bandwidth usage per vhost, like mod_bandwidth. However, since I started using nginx, I couldn't find a way of limiting and monitoring the bandwidth usage for each server block.

I would like to hear some suggestions regarding monitoring and limiting bandwidth usage per server block on nginx.

Best Answer

You can use limit_rate to limit the bandwidth. For me this also works on the community version of nginx.

For example the bandwidth can be limited to 1000 Bytes per second for the whole server block like this:

server {
    listen 80;

    location / {
        limit_rate 1k;
    }
}