fix(k8s): make LiteLLM emit https URLs behind the ingress - #97
Merged
Conversation
/kartik/ui redirected to http://<host>/kartik/ui/ instead of https. Browsers recovered on a second hop, but the first one was plaintext. LiteLLM takes uvicorn's defaults, so ProxyHeadersMiddleware is installed (proxy_headers=True) but only trusts 127.0.0.1 -- uvicorn falls back to FORWARDED_ALLOW_IPS or "127.0.0.1" (uvicorn/config.py:357). nginx connects from a pod IP, so X-Forwarded-Proto was discarded and the request scheme stayed http, which is what Starlette used to build the redirect. "*" is safe here: the Service is ClusterIP, so nothing outside the cluster can reach the pod directly to forge the header, and nginx overwrites it per request. Dev only, since prod and local don't expose the proxy through an ingress. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0174W6CHp7FMt7c9sKdBhbp1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #96. With the dashboard working, one wart remained:
/kartik/uiredirected tohttp://<host>/kartik/ui/rather thanhttps://. Browsers recovered on a second hop, but the first one was plaintext.Cause. LiteLLM takes uvicorn's defaults, so
ProxyHeadersMiddlewareis installed (proxy_headers=True) — butforwarded_allow_ipsfalls back toFORWARDED_ALLOW_IPSor"127.0.0.1"(uvicorn/config.py:357). nginx connects from a pod IP, soX-Forwarded-Proto: httpswas discarded, the request scheme stayedhttp, and that's what Starlette used to build the redirect.Why
*is acceptable here. ThelitellmService is ClusterIP, so nothing outside the cluster can reach the pod directly to forge the header, and nginx overwritesX-Forwarded-*on every request. The residual exposure is that an in-cluster caller could spoof the client IP in logs — no auth impact. Scoping to the ingress controller's pod CIDR would be tighter but brittle across cluster changes.Dev only, matching
SERVER_ROOT_PATH— prod and local don't expose the proxy through an ingress.Config-only, no image bump.
🤖 Generated with Claude Code
https://claude.ai/code/session_0174W6CHp7FMt7c9sKdBhbp1