How to limit request payload size using Spring Webflux?

时光毁灭记忆、已成空白 提交于 2019-12-22 00:17:37

问题


Using Spring Webflux, I need to limit the payload size of incoming HTTP requests (e.g. to say 5MB). Is this something configurable out-of-the-box? If not, which APIs can we use to implement this behavior (e.g. return a 413 if the payload is too big).


回答1:


I guess you want to do this to prevent Denial Of Service attacks by malicious or misbehaving clients.

The usual recommendation is to not directly connect HTTP application servers to the Internet, but instead via an HTTP reverse proxy server (such as a suitably configured Apache HTTPD or nginx). These proxy servers provide means for blocking large requests. They provide other facilities for blocking or mitigating bad clients.

You should therefore consider whether it would be easier not to implement this functionality in you application, and instead rely on the proxy doing it for you.



来源:https://stackoverflow.com/questions/57618682/how-to-limit-request-payload-size-using-spring-webflux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!