简体   繁体   English

NGINX client_max_body_size问题

[英]NGINX client_max_body_size issue

I have an issue about nginx client_max_body_size . 我对nginx client_max_body_size有问题。 I am getting an issue like 我遇到类似的问题

2017/09/11 13:21:02 [error] 6126#6126: *150091 client intended to send too large body: 1219514 bytes, client: 10.160.90.909, server: example.com, request: "POST /api/sensors HTTP/1.1", host: "example.com" . 2017/09/11 13:21:02 [错误] 6126#6126:* 150091客户端打算发送太大的正文:1219514字节,客户端:10.160.90.909,服务器:example.com,请求:“ POST / api / sensors HTTP / 1.1”,主机:“ example.com”。

Getting an 413 nginx error. 收到413 nginx错误。 I just want to know where should I add(insert) the client_max_body_size and what is the recommended mb you will suggest..? 我只想知道应该在哪里添加(插入)client_max_body_size,以及您建议的mb建议值..? Please find my nginx.conf file below 请在下面找到我的nginx.conf文件

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
    worker_connections 1024;
}
http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    index   index.html index.htm;
upstream nodejs {
    server localhost:3000;
}
    server {
        listen       80;
        server_name  example.com;

location / {
if ($http_x_forwarded_proto != 'https') {
            return 301 https://$server_name$request_uri;
        }
        try_files $uri $uri/ @nodejs;
    }

    location @nodejs {
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_pass http://nodejs;
        proxy_set_header Host $host ;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
location ~ (/images|/img|/javascript|/js|/css|/stylesheets|/flash|/media|/static|robots.txt|humans.txt|favicon.ico){
root /var/www/dev/public;
}
        # redirect server error pages to the static page /40x.html
        #
        error_page 404 /404.html;
            location = /40x.html {
        }
        # redirect server error pages to the static page /50x.html
        #
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
}
}

You need to insert it inside your @nodejs block. 您需要将其插入@nodejs块中。 Because the upload are being sent there. 因为上传文件被发送到那里。 You current failure indicates a size of 1.16 MB. 您当前的失败表明大小为1.16 MB。

So check what is maximum amount of data you want/expect to receive at a time. 因此,请检查一次您希望/期望接收的最大数据量。 So if you expect this to 5MB max then set it for 5.5MB or even higher to give some cushion 因此,如果您期望最大为5MB,则将其设置为5.5MB甚至更高,以提供一些缓冲

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM