Caddy not reverse proxying large requests to Fast API server

1. The problem I’m having:

I have a caddyFile running to do https reverse proxy to a fast api (python) server, everything works fine most of the time, however my problem is sometimes when the payload is large (about 500KB - 1MB of json strings), my gunicorn server never picks up the request from caddy, i don’t see logs on the gunicorn logfile (for these large requests, i do see logs for succesfull small ones) and this is the last log from caddy:

DEBUG   http.handlers.reverse_proxy     selected upstream       {"dial": "localhost:8000", "total_upstreams": 1}

Im trying to figure out if this is a caddy problem or my python gunicorn server problem, theres no specific logs in the python one so I’m assuming its the caddy layer that is the issue.

heres a successfull series of caddy logs in comparison (For smaller requests that succeed):

2023/03/24 05:47:06.816 DEBUG   http.handlers.reverse_proxy     selected upstream       {"dial": "localhost:8000", "total_upstreams": 1}

3. Caddy version:

v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy:

used Install — Caddy Documentation installed for linux thru command line, i run caddy with the below caddy file

b. Command:

caddy start

d. My complete Caddy config:

{
        debug
}

}

:8080 {
        respond "Hello, world!"
}

As far as I know, gunicorn has some weird characteristics that make it that request/response buffering in Caddy is sometimes necessary for it to behave properly. Try enabling request buffering:

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