Home 解决Http Code 414 (Request—URI Too Large) 错误
Post
Cancel

解决Http Code 414 (Request—URI Too Large) 错误

Fix 414 Too Large Request-URI

Ingress:

1
2
3
4
5
6
7
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/server-snippet: |
client_header_buffer_size 512k;
large_client_header_buffers 4 512k;

Spring Boot:

1
2
server:
max-http-header-size: 51200

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.maxHeaderSize(maxInitialLingLength) ;
            return httpRequestDecoderSpec;
            }
        ));
    }
}

weixin.png

公众号名称:怪味Coding
微信扫码关注或搜索公众号名称
This post is licensed under CC BY 4.0 by the author.