Nginx error: client intended to send too large body

老子叫甜甜 提交于 2021-02-07 12:01:10

问题


Periodically I get an error:

This site can't be reached.
The webpage at https://example.com/document might be temporarily down or it my have moved permanently to are new web address.

My site is stored on AWS. I use rails + nginx + passenger.

Nginx error log:

client intended to send too large body: 3729822 bytes, 
client: 172.42.35.54, server: example.com, 
request: "POST /document HTTP/1.1", host: "test.example.com", 
referrer: "https://test.example.com/document/new"

app log:

ActionController::RoutingError (No route matches [GET] "/document")

After a while, the error disappears. I have doubts that this is due to deployment, but I'm not sure. Could you please tell me, with what it can be related and how to fix such a problem?


回答1:


Default Nginx config limits client request body with 1Mb.
You have to increase client_max_body_size to allow users to post large documents.
Don't miss with the context (http, server, location) of this derictive and don't forget to reload configuration or restart Nginx after that.




回答2:


For me path of nginx.conf was /etc/nginx/nginx.conf.

In my case I just added client_max_body_size in http block and it worked for me

http {
    ...
    client_max_body_size 20M;
}    

Make sure to restart nginx after changing this config



来源:https://stackoverflow.com/questions/44741514/nginx-error-client-intended-to-send-too-large-body

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