"nginx + jetty" - post上传body size的限制问题
1 nginx配置修改, 增加红色字体部分 默认1M
client_max_body_size 0; //表示不限制
可以看到content_length
大于maxFormContentSize
时将抛出异常,而maxFormContentSize
默认是200000
path: /etc/nginx/nginx.conf
http { include /etc/nginx/mime.types; access_log /var/log/nginx/access.log; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; tcp_nodelay on; gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; client_max_body_size 0; //64M }
2 jetty配置修改 增加红色部分, 修改最多表单size
org.mortbay.jetty.Request.maxFormContentSize
-1表示不限制,默认200k
path: /etc/jetty/jetty.xml
<Call name="addConnector"> <Arg> <New class="org.mortbay.jetty.nio.SelectChannelConnector"> <Set name="host"><SystemProperty name="jetty.host" /></Set> <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set> <Set name="maxIdleTime">30000</Set> <Set name="Acceptors">2</Set> <Set name="statsOn">false</Set> <Set name="confidentialPort">8443</Set> <Set name="forwarded">true</Set> <Set name="forwardedServerHeader">ignore</Set> <Set name="forwardedHostHeader">ignore</Set> <Set name="lowResourcesConnections">5000</Set> <Set name="lowResourcesMaxIdleTime">5000</Set> </New> </Arg> </Call> <Call class="java.lang.System" name="setProperty"> <Arg>org.mortbay.jetty.Request.maxFormContentSize</Arg> <Arg>-1</Arg> </Call>
--------------------
tomcat默认允许的content-length=2×1024×1024
// 内容超长则直接返回,jetty会抛出IllegalStateException
protected void parseParameters() { ...... if (!("application/x-www-form-urlencoded".equals(contentType))) return; int len = getContentLength(); if (len > 0) { int maxPostSize = connector.getMaxPostSize(); // tomcat默认大小2*1024*1024 if ((maxPostSize > 0) && (len > maxPostSize)) { if (context.getLogger().isDebugEnabled()) { context.getLogger().debug( sm.getString("coyoteRequest.postTooLarge")); } return; // 内容超长则直接返回,jetty会抛出IllegalStateException //Parameters 对象没有内容 } ..... }
相关推荐
87901735 2019-05-29
lizhengfa 2019-05-17
smallwhale 2011-07-13
HatsuneMiku 2011-06-19
stoneechogx 2019-10-23
quguang 2019-10-23
sarsgetaway 2015-03-18
linuxprobe0 2017-09-23
星月高悬 2011-12-16
积跬步以至千里 2016-07-11
TyCoding 2016-04-08
onlylixiaobei 2015-01-04
CSDNMrWang 2011-05-19
tracyn 2014-04-28
TyCoding 2012-05-19
hwhanwan 2010-06-24
码路心路知行合一 2011-11-18