One visitor pulling a 4 GB file over a fast line can fill a small upload link. nginx can cap the speed per connection, and leave the start of every file at full speed.
location /downloads/ {
limit_rate_after 500k;
limit_rate 200k;
}
limit_rate is in bytes per second per connection, so 200k is about 200 KB/s. limit_rate_after lets the first 500 KB of each response go out without a limit. Pages, images and small files never notice the throttle, and only large downloads get slowed. Take a 1 MB file: without a limit it arrives at once, with only limit_rate 200k it takes about four seconds, and with the 500k head start about two.
A backend can also set the rate per response with an X-Accel-Limit-Rate header, which I find handy when the app knows who is a paying user.
The limit is per connection, not per visitor. A download manager that opens eight connections gets eight times the speed. To cap a client as a whole, combine it with limit_conn, so one IP can only open a few connections. Since nginx 1.17 the values can contain variables, so you can set them through a map, for example faster for your own network.
Further reading: limit_rate and limit_rate_after
Going deeper: 🛜 Guide: AdGuard Home + Tailscale (Secure Split-Horizon DNS)