出现413 Request Entity Too Large问题的解决方法
今日数据提交出现 http:413 Request Entity Too Large 错误。
解决问题后特此记录
今日数据提交出现 http:413 错误
经查是上传文件大小被限制了,将服务器限制了上传文件的大小设置成20M,重启服务并没有解决问题。
进一步跟进发现根本原因:
我们的tomcat是通过nginx发现服务代理的,nginx默认上传传文件的大小限制是1M,在nginx的配置中修改配置后可解决此问题。
解决方法如下:
1.打开nginx服务的配置文件nginx.conf
2.在http{}中加入client_max_body_size xxm, xx根据需求改动
3.保存后重启nginx,问题解决。
在服务器上部署了一套后台环境,使用的是nginx反向代理tomcat架构,在后台里上传一个70M的视频文件,上传到一半就失效了!
原因是nginx配置里限制了上传文件的大小
client_max_body_size:这个参数的设置限制了上传文件的大小,可以在http、server、location三个区域里配置
[root@dev-huanqiu ~]# cat /Data/app/nginx/conf/nginx.conf ....... ....... http { include mime.types; default_type application/octet-stream; charset utf-8; ####### ## http setting ####### sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 100; #这个参数表示http连接超时时间,默认是65s。要是上传文件比较大,在规定时间内没有上传完成,就会自动断开连接!所以适当调大这个时间。 fastcgi_connect_timeout 6000; fastcgi_send_timeout 6000; fastcgi_read_timeout 6000; fastcgi_buffer_size 256k; fastcgi_buffers 8 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; ## client_header_timeout 120s; #调大点 client_body_timeout 120s; #调大点 client_max_body_size 100m; #主要是这个参数,限制了上传文件大大小 client_body_buffer_size 256k; ## support more than 15 test environments server_names_hash_max_size 512; server_names_hash_bucket_size 128; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 9; gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php; gzip_vary on; [root@dev-huanqiu ~]# cat /Data/app/nginx/conf/vhosts/admin.wangshibo.conf server { listen 80; server_name admin.wangshibo.com; #if ($http_x_forwarded_for !~ ^(14.165.97.54|123.110.186.128|123.110.186.68)) { # rewrite ^.*$ /maintence.php last; #} access_log /var/log/wangshibo.log main; location / { proxy_pass http://127.0.0.1:8484/; proxy_connect_timeout 300; #这三个超时时间适量调大点 proxy_send_timeout 600; proxy_read_timeout 600; proxy_set_header X-Real-IP $remote_addr; # 获取客户端真实IP proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 获取代理者的真实ip proxy_set_header X-Forwarded-Scheme $scheme; # 解决getScheme,isSecure,sendRedirect proxy_buffer_size 32k; proxy_buffers 32 256k; proxy_busy_buffers_size 512k; proxy_temp_file_write_size 512k; } location /static/video { root /Data/app/tomcat-7-admin-wls/static/video; } } ##end server
本文由 admin 创作,采用 知识共享署名4.0
国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为:2022-08-09 22:51:31