Syntax: client_max_body_size size;Default: client_max_body_size 1m;Context: http, server, locationSets the maximum allowed size of the client request body, specified in the “Content-Length” request header field. If the size in a request exceeds the configured value, the 413 (Request Entity Too Large) error is returned to the client. Please be aware that browsers cannot correctly display this error. Setting size to 0 disables checking of client request body size.
①client_max_body_size 用来修改允许客户端上传文件的大小。默认为1m,如果设置为0,表示上传文件大小不受限制。
②可以在以下模块设置: http, server, location
③client_max_body_size 10m;
server {listen 80;server_name localhost;#charset koi8-r;# client_max_body_size 用来修改允许客户端上传文件的大小。默认为1m,如果设置为0,表示上传文件大小不受限制。# 可以在以下模块设置: http, server, location client_max_body_size 10m;# 访问 / 网站跟目录返回的内容location / {root /usr/share/nginx/html;index index.html index.htm;}...
}
http {include /etc/nginx/mime.types;default_type application/octet-stream;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;keepalive_timeout 65;# 是否开启压缩功能#gzip on;# client_max_body_size 用来修改允许客户端上传文件的大小。默认为1m,如果设置为0,表示上传文件大小不受限制。# 可以在以下模块设置: http, server, location client_max_body_size 10m; # 引用配置文件include /etc/nginx/conf.d/*.conf;
}
针对于该案例出现的问题,最快的解决方式(临时解决方案)是:进行nginx大小的调整,调整为可上传条件的大小为止。而针对这种最快的解决方式做了分析。
出现问题的原因:
用有限的思维来思考的问题,只想当下如何解决这个问题,没有从根本上解决问题。以后还可能有其他的情况,如果直接改参数,那么每次都需要改,而其中存在的风险是未知的。
解决问题的方案