springMVC 文件件上传大小限制, Nginx反向代理上传大文件

 

配置spring-mvc.xml

<!-- 上传文件配置 2048*1024*1024即2GB resolveLazily属性启用是为了推迟文件解析,以便捕获文件大小异常   -->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <!---->
        <!--<property name="maxUploadSize" value="2147483648"/>-->
        <property name="maxUploadSize" value="20480"/>
        <property name="maxInMemorySize" value="10240"/>
        <property name="defaultEncoding" value="UTF-8"/>
        <property name="resolveLazily" value="true"/>
    </bean>

配置ngnix

server {  
        listen 80;  
        server_name www.xxx.com;  
        location / {  
            client_max_body_size 2048m;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_pass http://localhost:8081;  
            index index.jsp index.html index.htm;  
        }  
    }

相关推荐