I am configuring Caddy reverse proxy for my Python application backend. However, sometimes Python backend (Waitress) can be slow to respond if the underlying database is overloaded. How can I configure reverse_proxy
to timeout on too slow requests? I see multiple timeout options in Caddy documentation. However, I could not find any written insight on how these should be used.
My assumption is that if the backend does not write any response headers, then response_header_timeout
is the correct timeout option to use. Currently, I am configuring my reverse proxy as following and I want to confirm it is what I hope it to be.
Also, what HTTP response Caddy will send if the reverse proxy upstream timeouts?
# Backend API request
handle /api* {
# This is the upstream Waitress server
reverse_proxy 127.0.0.1:3456 {
header_up X-Real-IP {remote_host}
# Backend API must respond to an individual API call under 20 seconds
transport http {
response_header_timeout 20s
}
}
}