Max_header_bytes and reverse proxy handler

1. Caddy version (caddy version):

Caddy 2

2. How I run Caddy:

Docker in Kubernetes

a. System environment:

docker

b. Command:

paste command here

c. Service/unit/compose file:

paste full file contents here

d. My complete Caddyfile or JSON config:

paste config here, replacing this text
DO NOT REDACT anything except credentials

3. The problem I’m having:

I’m looking to replicate this functionality from our Nginx configuration:

http2_max_field_size 16k;
http2_max_header_size 32k;

I’m getting an http status code 431 on reverse proxy requests that should be going to a mock server that we control. According to the mock server logs, it never receives the requests. Debug Caddy logs show that Caddy is returning a 431 status despite having the server configured with max_header_bytes set to a very large size.

Is the 431 status coming from a Go library dependency? Is there a way to increase headers to allow for very large cookies on reverse proxy requests? We own all of the domains that are the target of the proxying.

4. Error messages and/or full log output:

On any reverse proxy upstream request, I get a 431 Request Header Fields Too Large status, that goes away if I delete some of the cookies.

5. What I already tried:

I’ve tried various values for the max_header_bytes setting on the server, but none of them have had an effect. The largest size I specified on the server config was:

    "max_header_bytes": 128000000,

6. Links to relevant resources:

The 431 comes from the Go stdlib:

I’m not sure what the issue is here though. @matt may have more thoughts.

Can you fill out the help template? What’s your config? How are you running caddy, what is the request you’re making, etc? In other words, how can we see what you’re seeing?

One thought in the meantime:

Cookies are sent in headers, so… yeah, that makes sense. If the cookies are too big, it’ll blow up the header size.

This topic was automatically closed after 30 days. New replies are no longer allowed.