【问题标题】:Nginx error: client intended to send too large bodyNginx 错误:客户端打算发送太大的正文
【发布时间】:2017-11-28 05:15:29
【问题描述】:

我会定期收到错误:

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.

我的网站存储在 AWS 上。 我使用 Rails + nginx + 乘客。

Nginx 错误日志:

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"

应用日志:

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

过了一会儿,错误消失了。我怀疑这是由于部署造成的,但我不确定。您能否告诉我,它可能与什么相关以及如何解决此类问题?

【问题讨论】:

    标签: ruby-on-rails ruby amazon-web-services nginx amazon-ec2


    【解决方案1】:

    我已经更新/etc/nginx/nginx.conf

    就我而言,我在http block 中添加了client_max_body_size sendfile on;,如下所示

    http {
        ...
        sendfile on;
        client_max_body_size 20M;
    }
    

    client_max_body_size放在sendfile on;之后非常重要

    更新完nginx.conf后别忘了重启nginx

    对于 ubuntu

    sudo service nginx restart
    

    Centos

    sudo systemctl restart nginx
    

    【讨论】:

      【解决方案2】:

      对我来说nginx.conf 的路径是/etc/nginx/nginx.conf

      就我而言,我刚刚在http block 中添加了client_max_body_size,它对我有用

      http {
          ...
          client_max_body_size 20M;
      }    
      

      更改此配置后确保restart nginx

      【讨论】:

      • 按天保存。谢谢。
      【解决方案3】:

      Default Nginx 配置将客户端请求正文限制为 1Mb。
      您必须增加client_max_body_size 以允许用户发布大型文档。
      不要错过这个 derictive 的 context(http、server、location),之后不要忘记重新加载配置或重启 Nginx。

      【讨论】:

        猜你喜欢
        • 2021-04-20
        • 2015-08-09
        • 1970-01-01
        • 2021-10-28
        • 1970-01-01
        • 2019-01-22
        • 1970-01-01
        • 1970-01-01
        • 2020-11-08
        相关资源
        最近更新 更多