this repo keeps a minimum openresty configuration and some lua code, show you how to limit upload rate.
foo@bar> git clone https://github.com/luvjoey1996/resty-upload-rate-limit.git
foo@bar> cd resty-upload-rate-limit
foo@bar> mkdir logs
foo@bar> openresty -p `pwd` -c nginx.conf
foo@bar> curl 127.0.0.1:8888 -T {some file}
-- iter req body, limit upload speed in 200kb/s
for chunk in limit_recv_body(200) do
ngx.req.append_body(chunk)
end