Opened 5 years ago
Closed 5 years ago
#1799 closed defect (worksforme)
client_max_body_size ignored except at the bottom of http context
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | nginx-core | Version: | 1.14.x |
Keywords: | client_max_body_size context | Cc: | |
uname -a: |
# uname -a
Linux de01 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u3 (2019-06-16) x86_64 GNU/Linux |
||
nginx -V: |
# nginx -V
nginx version: nginx/1.14.1 built with OpenSSL 1.1.0f 25 May 2017 (running with OpenSSL 1.1.0j 20 Nov 2018) TLS SNI support enabled configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-jqo7Nx/nginx-1.14.1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-mail=dynamic --with-mail_ssl_module --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-auth-pam --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-dav-ext --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-echo --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-upstream-fair --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-subs-filter (Version 1.14.1-1~bpo9+1 from Debian stretch backports) |
Description
When attempting to PUT a resource of about 40MB to an nginx endpoint, the following was logged:
2019/06/26 13:45:10 [error] 17768#17768: *1 client intended to send too large body: 41011661 bytes, client: <redacted>, server: <redacted>, request: "PUT /<redacted> HTTP/1.1", host: "<redacted>"
This happened even with a setting of client_max_body_size 100M;
inside the server { }
context.
I also tried to put it into a location { }
context, both of which should work according to the documentation, but the same error was thrown.
Setting client_max_body_size 100M;
inside the http { }
context worked, but only if it was the very last entry.
Some googling found people with similar experiences, but not with any explanations.
It looks like this directive is ignored unless it is placed in certain very specific locations, contrary to what the documentation says. If this is not a bug, then the documentation should be clearer.
Here's a very brief reconstruction of my config and the locations I've tried to use the client_max_body_size
directive:
/etc/nginx/nginx.conf: http { client_max_body_size 100M; # Not bottom of http context - is ignored include /etc/nginx/sites-enabled/*; client_max_body_size 100M; # Is used } /etc/nginx/sites-enabled/somesite.conf: server { include /etc/nginx/conf.d/include.settings; } /etc/nginx/conf.d/include.settings: client_max_body_size 100M; # In server context - is ignored location /mylocation { client_max_body_size 100M; # In location context - is ignored }
Please provide full configuration which demonstrates the problem, as shown with
nginx -T
, and relevant request. Please avoid redacting anything - instead, please use a minimal test configuration without details you want to keep private.