<p>现象说明:</p><p>在服务器上部署了一套后台环境,使用的是nginx反向代理tomcat架构,在后台里上传一个70M的视频文件,上传到一半就失效了!</p><p>原因是nginx配置里限制了上传文件的大小</p><p>client_max_body_size:这个参数的设置限制了上传文件的大小,可以在http、server、location三个区域里配置</p><pre class="brush:bash;toolbar:false">[root@dev-huanqiu~]#cat/Data/app/nginx/conf/nginx.conf ....... ....... http{ includemime.types; default_typeapplication/octet-stream; charsetutf-8; ####### ##httpsetting ####### sendfileon; tcp_nopushon; tcp_nodelayon; keepalive_timeout100;#这个参数表示http连接超时时间,默认是65s。要是上传文件比较大,在规定时间内没有上传完成,就会自动断开连接!所以适当调大这个时间。 fastcgi_connect_timeout6000; fastcgi_send_timeout6000; fastcgi_read_timeout6000; fastcgi_buffer_size256k; fastcgi_buffers8256k; fastcgi_busy_buffers_size256k; fastcgi_temp_file_write_size256k; ## client_header_timeout120s;#调大点 client_body_timeout120s;#调大点 client_max_body_size100m;#主要是这个参数,限制了上传文件大大小 client_body_buffer_size256k; ##supportmorethan15testenvironments server_names_hash_max_size512; server_names_hash_bucket_size128; gzipon; gzip_min_length1k; gzip_buffers416k; gzip_http_version1.1; gzip_comp_level9; gzip_typestext/plainapplication/x-javascripttext/cssapplication/xmltext/javascriptapplication/x-httpd-php; gzip_varyon; [root@dev-huanqiu~]#cat/Data/app/nginx/conf/vhosts/admin.wangshibo.conf server{ listen80; server_nameadmin.wangshibo.com; #if($http_x_forwarded_for!~^(14.165.97.54|123.110.186.128|123.110.186.68)){ #rewrite^.*$/maintence.phplast; #} access_log/var/log/wangshibo.logmain; location/{ proxy_passhttp://127.0.0.1:8484/; proxy_connect_timeout300;#这三个超时时间适量调大点 proxy_send_timeout600; proxy_read_timeout600; proxy_set_headerX-Real-IP$remote_addr;#获取客户端真实IP proxy_set_headerREMOTE-HOST$remote_addr; proxy_set_headerHost$host; proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;#获取代理者的真实ip proxy_set_headerX-Forwarded-Scheme$scheme;#解决getScheme,isSecure,sendRedirect proxy_buffer_size32k; proxy_buffers32256k; proxy_busy_buffers_size512k; proxy_temp_file_write_size512k; } location/static/video{ root/Data/app/tomcat-7-admin-wls/static/video; } }##endserver</pre><p>另外,tomcat的server.xml配置文件中的connectionTimeout超时时间也可以适当调大点,默认是20000,可以改成60000.</p>
RangeTime:0.003233s
RangeMem:198.27 KB
返回顶部 留言