Skip to content
Discussion options

You must be logged in to vote

Classic TLS-terminating-proxy setup. The redirect loop comes from scope["scheme"] being http inside the container even though the client arrived over HTTPS. Fix is to normalize the ASGI scope before HTTPSRedirectMiddleware runs: uvicorn app:app --proxy-headers --forwarded-allow-ips '*' (or a specific CIDR), or wrap manually with ProxyHeadersMiddleware from uvicorn.middleware.proxy_headers. Folding x-forwarded-proto handling directly into HTTPSRedirectMiddleware would force trusted-proxy config into every header-aware middleware, fixing it once at the edge is cleaner.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@stdedos
Comment options

Answer selected by stdedos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants