开发者

Nginx: check content-length before file upload takes place

开发者 https://www.devze.com 2023-03-14 01:06 出处:网络
I\'m trying to prevent users from uploading (accidentally or maliciously) very large files to my website.

I'm trying to prevent users from uploading (accidentally or maliciously) very large files to my website.

I have nginx max_client_body_size set to 4M, but if a file larger than this is uploaded, then it uploads the entir开发者_Python百科e file before returning 413 (entity too large).

I want to make nginx check the Content-Length header, so that it rejects the request before it's uploaded.

Alternatively, a Rails solution would also be acceptable.

Any help appreciated.


You may set lingering_time 0; # default is 30s

lingering_time sets how long nginx will read discarded body before closing connection.

0

精彩评论

暂无评论...
验证码 换一张
取 消