Limit_rate for POST targets?

Is there a module that does throttled reading for POST and works the
way as limit_rate does for GET (per stream, X bytes per second).

I got some kind of throttle effect by putting a usleep() into the
os/unix/ngx_recv.c file reader, but I want to use something that works
same way as limit_rate.


Anyone? no ideas?

how would i go about getting such a feature added. I imagine it would be
much the same code, just applied to reading the request body rather than
writing it. And since it is core functionality I’m not sure one for POST
should be an extension?

The docs
suggest using ‘if’, even though it is uncertain under which conditions
directive works/should be used or not…

You could either set the logic in ‘if’ or use a map matching the
$http_method variable and setting an intermediary variable which will be
used in turn by ‘if’ to set the rate_limit feature or not.
​That is the most efficient way of doing that I can think of.​

B. R.

Lua would be a way to go,
ea. GitHub - TiVo/lua-resty-rate-limit

Posted at Nginx Forum:

limit_rate it only applies to GET
( and works great )

“response transmission to a client”

but not POST (reading data from a client)

I do not get (aha) where you saw limit_rate only applies to the GET
But yeah limit_rate applies to resposnes.

Rate limiting only properly applies to sender, in your case the client,
which is the sole entity ablte to properly craft its requests to contain
specified amount of data/time period.
​The only thi​ng you can limit on intermediaries/receiver is
connections/packets, because it is network-related structures which are
trivial to handle/buffer.

Rate-limiting on a transmitting/receiving end requires buffering content
(not envelope, so that means application logic/DPI), and re-crafting
forwarded/processed content into suitable network envelopes.
Way too expensive/dangerous/demanding.

You can limit incoming transmissions in nginx based on connections
(limit_conn) or requests (limit_req).
You can limit incoming transmissions at TCP level in firewalls surch as
iptables based on connections and/or packets.

​My 2 cents,​

B. R.

hmm that is rate limiting req/s

i am looking for an exact limit_rate equivalent - which is

It is true that the best way to rate limit is the sender. But in the
where the sender is a myriad different browsers, that isn’t an option.
There is no control at the POST level to throttle an upload. There isn’t
really any good firewall tool for traffic shaping incoming data per tcp
stream either. You can traffic shape to a port, but not as easily per

For a particular application I’d like to simulate the effect of
at a specific rate. Since I got the desired effect by crudely limiting
rate at which nginx reads its input socket (with usleep) it seemed
that a mirror of the limit_rate code for sending could be applied to
reading as well.

It wouldn’t be ideal, but if the server was dedicated to this and not
things, I’m not sure it would have any disastrous effects?