tomcat加nginx post请求大数据量过大解决合集(Spring boot)

wylc123 1年前 ⋅ 1017 阅读

1.修改tomcat配置文件server.xml

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000" 
               redirectPort="8443" maxPostSize="-1" URIEncoding="UTF-8"/>

添加:maxPostSize="-1",tomat7版本以下配置maxPostSize="0"

2.springboot配置文件设置:

server:
  #url: http://localhost
  port: 8080
  max-http-header-size: 4048576
  maxPostSize: -1
  tomcaturi-encoding: UTF-8
  tomcat:
      max-http-post-size: -1
spring:
  http:
    multipart:
      max-file-size: -1 #注意单位
      max-request-size: -1 #32MB #注意单位
server.max-http-header-size = 4048576
server.maxPostSize = -1
server.tomcat.max-http-form-post-size= -1
pring.http.multipart.max-file-size=-1
spring.http.multipart.max-request-size=-1

3.nginx配置文件nginx.conf

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    client_max_body_size 100m;
    
    upstream bdms-juntu-service {
        server 211.103.242.83:8080;
    }
	

    map $http_x_forwarded_proto $the_scheme {
        default $http_x_forwarded_proto;
        "" $scheme;
    }

    map $http_x_forwarded_host $the_host {
        default $http_x_forwarded_host;
        "" $host;
    }

    map $http_upgrade $proxy_connection {
        default upgrade;
        "" close;
    }

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $proxy_connection;
    proxy_set_header X-Forwarded-Proto $the_scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    
    server {
        listen       80;
        server_name  localhost;
        
        location /api/ {
			client_max_body_size 1000m;
            proxy_pass http://bdms-juntu-service/;
            proxy_http_version 1.1;
            proxy_set_header X-Forwarded-Host $the_host/api;
            proxy_set_header Host $host:$server_port;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $proxy_connection;
			proxy_pass_header X-XSRF-TOKEN;
			proxy_set_header Origin '';
			proxy_read_timeout 300s;
        }

        location / {
            root   D:/bdms/bdms-page-juntu;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
			proxy_http_version 1.1;
        }



        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

}

client_max_body_size 1000m;

更多内容请访问:IT源点

相关文章推荐

全部评论: 0

    我有话说: