Fix 413 Request Entity Too Large
Ingress:
1
2
3
4
5
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: 10m
Spring Boot:
1
2
3
4
5
6
server:
servlet:
multipart:
enabled: true
max-file-size: 50MB
max-request-size: 300MB
Spring Cloud Gateway:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@Component
public class NettyConfig implements WebServerFactoryCustomizer<NettyReactiveWebServerFactory> {
/**
* 10m
*/
@Value("${server.max-initial-line-length:10485760}")
private int maxInitialLingLength;
@Override
public void customize(final NettyReactiveWebServerFactory factory) {
factory.addServerCustomizers(httpServer -> httpServer.httpRequestDecoder(httpRequestDecoderSpec -> {
httpRequestDecoderSpec.maxInitialLineLength(maxInitialLingLength);
return httpRequestDecoderSpec;
}
));
}
}
