Bandwidth management with NGINX
If you're serving large binary files (such as video files), it's important to ensure that you fairly distribute your available bandwidth among your users. At the same time, you must ensure that this distribution doesn't impact performance nor inconvenience users by setting restrictions that are too high.
Getting ready
The modules required are built into the NGINX core, so no upgrades or external modules are required. In this recipe, we'll serve static files, but they can be easily incorporated into your existing site.
How to do it...
Limiting bandwidth must be done within a location
directive. It's important to ensure that, if you have multiple location
block directives which you want to limit, you need to adjust each of these. Here's our basic code:
server { listen 80; server_name limitbw.nginxcookbook.com; access_log /var/log/nginx/limitbw.log combined; location / { limit_rate 5m; root /var/www/html; index index...