Skip to content

docs: LiteLLM Hardened Production Stack Documentation - #39405

Open
myu1d157h0u54nd wants to merge 4 commits into
BerriAI:mainfrom
myu1d157h0u54nd:docs-enhancement-docker-compose-hardened
Open

myu1d157h0u54nd wants to merge 4 commits into
BerriAI:mainfrom
myu1d157h0u54nd:docs-enhancement-docker-compose-hardened

Conversation

@myu1d157h0u54nd

Copy link
Copy Markdown

This document outlines the production-grade deployment guidelines for the LiteLLM Proxy infrastructure. The system is engineered as a single, unified architecture offering two configurable egress topologies: Direct Egress and Proxy-Filtered Egress (Squid). The underlying design emphasizes container isolation, OWASP-compliant secrets management, and strict network segmentation through a Zero-Trust internal model.

TLDR

  • Simplifies production LiteLLM Proxy deployment with hardened security defaults
  • Provides two egress topologies: direct or Squid-filtered for data exfiltration protection
  • Reduces operational friction via automated secret generation and health validation
    Problem this solves
  • Operators lack reproducible, secure LiteLLM deployment scripts with consistent networking
  • No standardized way to enforce egress filtering or container security hardening
  • Manual secret management and firewall configuration introduces risk and variability
    How it solves it
  • Generates cryptographically secure secrets with restricted host file permissions
  • Renders compose.yaml from a validated template with optional Squid proxy integration
  • Validates UFW firewall rules and waits for all services to report healthy status
  • Supports optional systemd service registration for boot persistence
    User Flow
    Before: Manual deployment without hardening
  1. Operator manually creates Docker containers without security configurations
  2. Secrets are stored in plaintext or inconsistent locations on the host
  3. Firewall rules for port 4000 are configured ad-hoc, if at all
  4. No health validation; containers may start in unknown state
  5. Optional systemd service requires manual unit creation and enablement
    After: Deploy using deploy.sh template
  6. Runner executes sudo ./deploy.sh --force-open-firewall (or with proxy/systemd flags)
  7. Script generates secrets in ./secrets/ with 600 permissions mapped to UID 101:101
  8. compose.yaml is rendered from compose.yaml.template with correct env mappings
  9. UFW rules are validated/created for port 4000/tcp with 'LiteLLM Proxy' comment
  10. All containers healthcheck; progress bar displays wait status up to 180s
  11. Systemd unit litellm.service is registered/enabled if --install-systemd passed
  12. Master key displayed at completion for UI login at http://127.0.0.1:4000/ui/login/
    (Steps 1–3 are identical in both flows; divergence begins at step 4 with firewall/proxy selection.)
    Relevant issues
  • —
    Linear ticket
    —
    Screenshots / Proof of Fix
    Since this is an infrastructure/ops PR, proof takes the form of:
  • Before: docker compose ps showing containers without health status; ufw status missing port 4000 rule
  • After: docker compose ps showing all services "Health":"healthy"; ./secrets/master_key.txt readable only by root; docker compose ps --format json confirming UID 101:101 ownership
  • Command sample: sudo ./deploy.sh --force-open-firewall --enable-egress-proxy followed by curl http://127.0.0.1:4000/health returning 200 OK
    Structure per the template: Before and After one heading level below this section, each naming the commit hash it was captured at, one lower-level heading per case inside each, the same case names in the same order on both sides, and numbered steps (command, observed output) under every case.
    Type
    🚄 Infrastructure
    Caveats (if any)
    Severe: Inherent to deployment configuration
  • FORCE_FIREWALL flag required if UFW is active; deployment will fail without it on secured hosts
  • --enable-egress-proxy introduces Squid as a dependency; if Squid container fails to start, all egress is blocked
  • Secrets are stored in ./secrets/ on the host; improper chmod or host-level access compromises credential security
    Medium: Operational gaps someone can hit
  • LITELLM_DISABLE_NO_REDIS_WARNING=true suppresses Redis banner only; rate limiting without Redis may have reduced accuracy
  • tmpfs sizes (/app/cache: 256m, /app/migrations: 64m) may need adjustment for production workload volume
  • Systemd unit assumes docker binary is on $PATH; non-standard installs may fail
    Low: Edge cases and cleanup
  • Teardown sudo docker compose down -v --remove-orphans leaves postgres_data volume unless manually removed
  • Sparse-checkout workflow requires git and docker; offline or restricted environments cannot use this flow
    QA runbook
  • Run sudo ./deploy.sh --force-open-firewall from /opt/litellm/src/docker-compose
  • Verify ./secrets/master_key.txt exists and is readable only by root: sudo stat -c '%A %U %G' ./secrets/master_key.txt
  • Verify UFW rule added: sudo ufw status | grep "LiteLLM Proxy"
  • Sanity check: docker compose ps shows all services healthy within 180s
  • tests/e2e/deployment/test_deploy_e2e.py::TestDeploy::test_topology_direct_vs_proxy - Direct mode works without Squid; Proxy mode routes egress through Squid
  • Run sudo ./deploy.sh --force-open-firewall (Direct)
  • Run sudo ./deploy.sh --force-open-firewall --enable-egress-proxy (Proxy)
  • For proxy: curl http://127.0.0.1:4000/ui/login/ returns login page
  • Sanity check: both topologies produce healthy service sets
    Note environment prerequisites (root, UFW, Docker Engine 20.10+, Docker Compose V2) and any nuances a manual run will hit. See PRs test(e2e): cover key rpm/tpm rate limiting, window reset, and pacing headers #32914 and test(e2e): cover model-aware mid-conversation system handling on Bedrock Invoke /v1/messages #32963 for full examples.

@CLAassistant

CLAassistant commented Sep 2, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces the repository-root development and hardened Compose files with a generated production deployment stack supporting direct and Squid-based egress. It adds secret provisioning, firewall checks, health polling, optional systemd installation, and an operator deployment guide

  • Removes the existing root Compose entrypoints
  • Adds a hardened Compose template and root-only deployment script
  • Adds optional Squid proxy configuration and systemd integration
  • Adds production installation and operations documentation

Confidence Score: 2/5

This PR should not merge until the removed Compose interfaces are preserved and proxy mode actually enforces the promised egress boundary

Existing documented development commands lose their Compose files, and the replacement proxy topology permits both direct outbound routing and unrestricted proxy destinations

Files Needing Attention: docker-compose.yml, docker-compose.hardened.yml, docker-compose/compose.yaml.template, docker-compose/deploy.sh

Security Review

Proxy-filtered mode does not enforce its stated egress boundary because LiteLLM retains direct internet routing and Squid permits arbitrary destinations on ports 80 and 443

Important Files Changed

Filename Overview
docker-compose.yml Deletes the established root development stack without preserving compatibility for documented repository-root Compose workflows
docker-compose.hardened.yml Deletes the established hardened Compose entrypoint and leaves existing hardened-stack instructions referencing a missing file
docker-compose/compose.yaml.template Adds a valid hardened Compose template, but proxy mode retains a direct public-egress route that bypasses Squid
docker-compose/deploy.sh Adds provisioning and lifecycle automation, but its Squid policy allows arbitrary HTTP and HTTPS destinations
docker-compose/README.md Adds comprehensive customer-facing production deployment documentation in a repository where product documentation belongs elsewhere

Comments Outside Diff (1)

  1. docker-compose.yml

    P1 Root Compose Interface Removed

    Existing documented root-level Compose commands now lack configuration files, causing development, database, Prometheus, and hardened-stack startup commands to fail.

    Rule Used: What: avoid backwards-incompatible changes without... (source)

    Knowledge Base Used: Proxy configuration and deployment

Reviews (1): Last reviewed commit: "LiteLLM Hardened Production Stack Docume..." | Re-trigger Greptile

Comment on lines +38 to +40
networks:
- public-egress
- backend-internal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Proxy Egress Remains Unrestricted

In proxy mode, LiteLLM retains direct internet routing, while Squid permits arbitrary destinations on ports 80 and 443, defeating filtered egress.

How this was verified: The network remains externally routed and the complete Squid policy ends with http_access allow all.

Comment thread docker-compose/README.md
Comment on lines +1 to +3
# LiteLLM Hardened Production Stack Documentation

This document outlines the production-grade deployment guidelines for the LiteLLM Proxy infrastructure. The system is engineered as a single, unified architecture offering two configurable egress topologies: **Direct Egress** and **Proxy-Filtered Egress (Squid)**. The underlying design emphasizes container isolation, OWASP-compliant secrets management, and strict network segmentation through a Zero-Trust internal model.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Product Documentation Added In-Tree

This operator-facing production guide belongs in litellm-docs; keeping it here splits publishing and maintenance across repositories.

Rule Used: Prevent documentation about the LiteLLM product fr... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment thread docker-compose/deploy.sh
if command -v ufw >/dev/null 2>&1; then
UFW_STATUS=$(ufw status | grep -i "status: active" || true)
if [ -n "${UFW_STATUS}" ]; then
PORT_ALLOWED=$(ufw status | grep -E "${TARGET_PORT}(/tcp)?.*ALLOW" || true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Redundant Script Comments Added

Ordinary section labels and narration duplicate straightforward commands throughout this script, violating the source-comment policy and adding maintenance overhead.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@myu1d157h0u54nd myu1d157h0u54nd changed the title LiteLLM Hardened Production Stack Documentation docs: LiteLLM Hardened Production Stack Documentation Sep 2, 2026
Comment thread docker-compose/deploy.sh
acl CONNECT method CONNECT
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow all

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: Proxy mode does not enforce filtered egress

http_access allow all permits requests to every HTTP/HTTPS destination, and the LiteLLM container remains attached directly to the non-internal public-egress bridge. An attacker who can induce or execute an outbound request can therefore send data to an arbitrary host, either through Squid or by bypassing it; use destination allowlists and a network topology where only the egress gateway has an external route.

Comment thread docker-compose/deploy.sh
echo -e "${GREEN}=====================================================${NC}"
echo -e " ${BOLD}URL:${NC} http://127.0.0.1:${TARGET_PORT}/ui/login/"
echo -e " ${BOLD}User:${NC} admin (or Bearer Token / UI Auth)"
echo -e " ${BOLD}Password:${NC} ${YELLOW}${LITELLM_MASTER_KEY}${NC}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: Administrator key exposed in deployment output

This prints the master key verbatim, so anyone with access to captured provisioning output, CI logs, or terminal-session logs can authenticate as the administrator. Keep the key only in the restricted secret file and print the command or path needed to retrieve it instead.

@veria-ai

veria-ai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

This pull request documents and provides deployment automation for a production LiteLLM stack using Docker Compose, including proxy-based egress and generated service credentials.

Three issues remain open around unrestricted outbound connectivity and credential handling. The deployment can expose the administrator key through logs, leave generated secrets vulnerable to accidental Git commits, and allow arbitrary external destinations; exploitation generally requires access to deployment artifacts, repository contents, or the ability to induce outbound requests. No issues have yet been addressed.

Open issues (3)

Fixed/addressed: 0 · PR risk: 4/10

Comment thread docker-compose/deploy.sh
fi

# Provision Secrets
mkdir -p -m 700 "${SECRETS_DIR}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: Generated credentials are not excluded from Git

This creates the secrets directory inside the cloned repository, while the current .gitignore does not exclude docker-compose/secrets/. Add that directory to the repository's ignore rules so a routine git add -A cannot commit the master key, salt key, and database credentials.

@yuneng-berri
yuneng-berri deleted the branch BerriAI:main September 13, 2026 04:48
@yuneng-berri yuneng-berri reopened this Sep 13, 2026
@devin-ai-integration
devin-ai-integration Bot changed the base branch from litellm_internal_staging to main September 23, 2026 14:46
@devin-ai-integration
devin-ai-integration Bot requested a review from a team September 23, 2026 14:46

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants