Envoy: How to set max resposne header limit

Created on 30 Oct 2020  路  3Comments  路  Source: envoyproxy/envoy

I use envoy as a reverse proxy but I found that it has a max response header limit. I use envoy to proxy an upstream server, which will use this codes to add a lot of response headers:

func handleRequest(ctx *gin.Context) {
    headerNum := 97
    for i := 0; i < headerNum; i ++ {
        ctx.Writer.Header().Add("X", fmt.Sprintf("%03d", i))
    }
    ctx.String(http.StatusOK, "ok")
}

And I noticed that if I set headerNum to 98 and request envoy proxy for accessing this upstream server, I will get an error and have a 503 status code:

upstream connect error or disconnect/reset before headers. reset reason: connection termination

It seems that envoy has a limit for the number of response header. So where can I set this configuration?

Also If I use ext_authz to send lots of headers from external auth server to upstream servers, this header limit can also influence this function.

areconfiguration question

All 3 comments

@weixiao-huang Http connections have an option max_headers_count to it. See max_headers_count and max_response_headers_count.

You set it through common_http_protocol_options in your cluster configuration

It works! Thanks for your answer!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anatolebeuzon picture anatolebeuzon  路  3Comments

sabiurr picture sabiurr  路  3Comments

karthequian picture karthequian  路  3Comments

jeremybaumont picture jeremybaumont  路  3Comments

hzxuzhonghu picture hzxuzhonghu  路  3Comments