How Nginx load balancing fits vLLM on Docker hosts
A team running one vLLM server that needs more throughput can add several vLLM containers on Docker hosts and place Nginx in front of them, using least-connection balancing and an endpoint allowlist at the proxy. Nginx distributes each new request to the replica with the fewest open connections, which suits LLM traffic because response times vary widely with prompt and output length. The allowlist then exposes only the paths meant for users, while the replicas stay on a private network. This is a horizontal scaling method for a single host or a small set of Docker hosts that you control, and it does not replace Kubernetes scheduling, autoscaling or multi-node model sharding. Each replica still loads the full model onto its own accelerators, so the method adds request capacity, not larger models.
The design depends on a few vLLM behaviors you should confirm before you build. The vLLM security documentation states that the --api-key option does not protect /invocations, /pause, /resume, /abort_requests, /metrics or /health, and it recommends a reverse proxy that allowlists only user-facing endpoints. That makes the proxy configuration a security control, not only a routing convenience, so the allowlist should be tested against every path your replicas expose. Failure detection also needs a plan: Nginx open-source passive health checks mark a failed upstream after errors, but you should confirm the exact directives and behavior for your Nginx build. Each replica should also be checked through /health and its Prometheus /metrics endpoint so you can see queue depth and KV cache use per container.
Shared model cache and the accelerator layout are the decisions that most affect cost and risk. Mounting one model cache volume read-only into every container avoids repeated downloads, but you should confirm how your vLLM version handles concurrent reads and which model files it writes at startup. Each container needs dedicated GPUs or a documented split of devices, and the GPU count per replica sets how many containers one host can run. Ask whoever operates the hosts to confirm driver, container runtime and network placement, and to write down the failure behavior of a replica that stops mid-stream. Those answers determine whether the design holds for your traffic.
What the Docker hosts and proxy need before the build
A horizontally scaled vLLM setup on Docker hosts depends on a few components being settled before any container starts. Each card below is a prerequisite that the later build steps assume, and each names the check to run before committing hardware or time.
Docker hosts with GPU access
Each vLLM container needs a host with the accelerator driver installed and a container runtime that can pass GPUs into the container. Plan one host per replica or several replicas per host, and size each host's GPUs to the model you intend to serve. Confirm the GPU runtime setup, driver versions and device flags against the vLLM installation docs before ordering hardware, because the supported accelerator list differs by platform.
vLLM installation docsA pinned vLLM version tested against your model
Pin one vLLM image tag across every replica so that all backends answer requests the same way. vLLM ships new minor releases about every two weeks, so the tag you pick today may be superseded quickly. Test the pinned version with your exact model, chat template and flags on one host first. The current release line includes v0.31.0, released October 5, 2026, but confirm that the version you test is still supported when you build.
Nginx build and TLS certificates
Choose an Nginx build that includes the upstream and proxy modules you need, and plan the certificate used on the client-facing listener. Decide who issues and renews the certificate and how the proxy trusts it. Certificates should cover the external hostname only, while traffic between the proxy and the vLLM containers stays on the internal network. Record the Nginx version and the renewal process before the build, so that a later reload does not become the first test of the certificate.
Shared model storage path
Every replica should load weights from the same path, so that a model update is made once and no host drifts to a different checkpoint. A read-only network mount or a replicated file store works, but check the mount is reachable from every GPU host and that container users have read permission. Ask your storage team how large the model directory is, how quickly it loads over the network, and who approves changes to it, because a slow or unavailable mount turns into slow or failed container starts.
Internal network between proxy and containers
Put the proxy and the vLLM containers on a private network that clients cannot reach directly. vLLM's own API key does not protect every endpoint, and its security documentation recommends a reverse proxy that allowlists only the endpoints meant for users. Decide which host ports are published, which stay internal, and how the Docker network is named and segmented. Confirm that the metrics and health paths are reachable only from monitoring systems.
Confirmed health and metrics endpoints
The load balancer needs a reliable signal for when a replica is ready to take traffic. vLLM exposes Prometheus-format metrics at /metrics, and the health endpoint is part of the set the proxy must not expose to users. Before the build, verify on your pinned version which health path answers after a model finishes loading, and note how long a cold start takes on your hardware. Those two facts set the failure-detection thresholds you will configure in Nginx.
Configuring the Nginx upstream for vLLM containers
This sequence turns several single-GPU-group vLLM containers into one proxied endpoint, with least-connection routing, failure detection, and an allowlist that exposes only the /v1 paths to users. Each step ends with a check you can run before moving on.
Start one vLLM container per GPU group
Your platform engineer starts one vLLM container per GPU group with
vllm serve, pointing each container at the same model directory on a shared, read-only mount so every replica loads identical weights. Bind each server to a private Docker network address rather than a host port that the public listener can reach directly, and pin the same image tag on every container. Confirm each container loads the model by calling/v1/modelsdirectly from the proxy host. Done means every replica returns the same model ID, and you have recorded which GPUs each container uses so a later failure can be traced to hardware.Confirm the chat template on every replica
Before the proxy goes live, check that each replica can serve the chat completions API. Models must provide a chat template, or receive one through
--chat-template, and a replica that differs from its peers will fail only some requests. Send one request to/v1/chat/completionsagainst each container directly, not through Nginx. Done means every replica returns a valid completion for the same test prompt, and any mismatch in the template or startup flags is fixed before the upstream is added.Define the upstream block with least_conn
Your network or platform engineer adds an
upstreamblock to the Nginx configuration listing each vLLM container's private address and port, and sets theleast_conndirective so new requests go to the replica with the fewest active connections. Long generations hold connections open, so round-robin tends to pile work onto a replica that is already busy. Setmax_failsandfail_timeouton each member so Nginx marks a replica as unavailable after repeated failed connections. Runnginx -tto validate the syntax, then reload. Done means the configuration validates and the upstream lists every intended replica.Allowlist the /v1 paths on the public listener
Your security engineer adds a
locationblock on the public server that proxies only the paths users need:/v1/completions,/v1/chat/completions,/v1/responses,/v1/embeddingsand the audio transcription and translation routes, plus/v1/modelsif clients call it. Use exact or prefix matches for these paths only. vLLM's--api-keyoption does not cover/invocations,/pause,/resume,/abort_requests,/metricsor/health, so the proxy must be the control that keeps those reachable only from inside. Done means the allowlist is written as explicit paths, not a catch-all, and every other path returns a denial.Deny metrics, health and control endpoints publicly
Add explicit
deny allrules, or a catch-allreturn 404, for/metrics,/health,/pause,/resume,/abort_requests,/invocationsand the other control routes on the public listener. Keep the metrics scrape and health checks on an internal listener that your monitoring system can reach. The vLLM security documentation recommends a reverse proxy that allowlists only user-facing endpoints, so this step is where that recommendation is enforced. Done means a request from outside to/metricsor/pauseis refused at Nginx, while the same path still answers on the internal listener from your monitoring host.Verify routing through the proxy
Send a set of requests through the public listener: a call to
/v1/models, a chat completion, and several concurrent requests. Check the Nginx access log to confirm requests spread across replicas, and confirm that a request to/metricsreturns a denial. Compare the metrics at each replica's/metricsendpoint on the internal network to see that load is distributed. Done means each allowed path returns a valid response, denied paths are refused, and load appears on more than one replica.Test failover by stopping one replica
Stop one vLLM container while sending a steady stream of test requests through the proxy. Expect requests to that replica to fail briefly until Nginx marks it unavailable, after which traffic should flow only to the remaining containers. Check the error log and confirm the stopped replica no longer receives connections. Restart it and confirm it rejoins rotation once
fail_timeoutexpires and a request succeeds. Done means the stopped container drops out of rotation without a full outage, and returns to rotation when healthy. Record how many client requests failed during the window so you can set expectations with the application team.
Where the shared model cache and metrics should live
When all vLLM containers run on one Docker host, the simplest layout is one copy of the model weights on the host disk, mounted read-only into every vLLM container. Each container reads the same files, so you pay the disk cost once and a new replica does not download the model again. The trade-off is that the weights are a single point of failure for the host, and every replica competes for the same disk and memory bandwidth during model load. Treat the host as the unit of recovery: if the disk fails, the whole pool stops until the weights are restored.
- Read-only mount: Mount the model directory with
:roso a misbehaving container cannot alter or delete weights that other replicas use. - Separate cache path: Point
HF_HOMEat a directory you control so downloads do not land in a container's writable layer. - Restart cost: A replica restarted on the same host reloads weights from local disk, which is usually much faster than a network pull.
- Shared failure domain: GPU, disk and Nginx all sit on one machine, so plan for host-level backups and a documented rebuild.
- Metrics path: Prometheus can scrape each container over the Docker network, and Nginx should never proxy
/metricsto users.
Confirm with your own environment how your storage driver and filesystem handle concurrent reads on the model volume and what your hardware vendor recommends for load throughput.
Across several hosts, you can either mount a network file share that every host reads or pre-sync an identical copy of the weights to each host from a controlled artifact store. A network share centralizes updates, so a new model version is published once. It adds a dependency on the file server and the network, and model loads become sensitive to throughput and latency on that path. Pre-synced copies remove the runtime dependency but require a checksum step and a rollout process so that hosts do not drift to different model revisions.
- Network file share: Reads during startup can be slow on congested links, so measure load time before you rely on it for fast replacement.
- Pre-synced weights: Each host keeps a local copy, so a replica restart does not depend on a remote service, at the cost of more total disk.
- Version pinning: Record the model revision and file checksums per host so every Nginx upstream serves the same weights.
- Access control: Restrict the share to the vLLM hosts and to the account that mounts it, and avoid granting write access to serving hosts.
- Staged rollout: Update one host at a time and keep Nginx from routing to it until its health check passes.
Ask your storage team how the share handles locking, caching and failover, and test a full cold start from the share before you size the pool.
vLLM exposes Prometheus-format metrics at /metrics on its API server. That endpoint is not covered by the --api-key option, so it must never be reachable through the public Nginx listener. The safe pattern is a second, internal-only path: Prometheus reaches each vLLM container directly on a private Docker network, or through a dedicated Nginx server block that binds to an internal address and is excluded from user traffic. The metrics reveal request volumes, latency distributions and KV cache pressure, which are useful to attackers as well as operators.
- Private network: Place Prometheus and the vLLM containers on a network that the public proxy is not attached to.
- Internal listener: If Nginx fronts metrics, bind that server block to a private interface and allowlist the Prometheus address only.
- Proxy allowlist: Deny
/metrics,/healthand the control endpoints on the public listener, and allow only the inference paths meant for users. - Histogram buckets: Review the configurable histogram buckets so latency panels reflect your service-level targets.
- Scrape scope: Scrape each replica by its own address so a single unhealthy container shows up in its own series.
Confirm with your security team which network segments may reach the metrics port and whether your monitoring platform requires authentication on the scrape path.
How failure detection and health checks behave behind Nginx
Open-source Nginx checks upstreams passively. The max_fails and fail_timeout parameters on each server line in an upstream block mark a backend as unavailable after repeated failed proxied requests, and keep it out of rotation for the timeout window. Active health checks, which probe each backend on a schedule whether or not user traffic is flowing, are a separate capability that depends on the Nginx build or a third-party module. Before you design around either, confirm with your package or vendor documentation which of the two your Nginx package provides, and test the behavior in your own environment rather than assuming it from the configuration file.
The gap that matters most for vLLM is startup. A container can accept a TCP connection while it is still loading model weights into accelerator memory, so a passive check may find it healthy and route requests to it. Those requests can fail with connection errors or server errors, which count toward max_fails, and the backend is then removed for a period even though it is about to become ready. Illustratively, if a host runs three replicas and one is restarting after a failure, a poorly timed restart can push a burst of errors through the proxy before the replica is pulled. The practical controls are to start new replicas outside the proxy pool, add them only after they answer a readiness probe, and tune max_fails and fail_timeout against observed startup times.
For an external check, use the /health endpoint on the vLLM server from a probe that runs outside the public listener, such as a sidecar, a host script or your monitoring agent, and have that probe update the upstream list or alert an operator. Do not expose /health through the public server block, because the vLLM security guidance lists it among endpoints that the --api-key option does not protect. Treat /health as a liveness signal, not proof of readiness for chat or completion requests, and confirm the exact response it gives for a model that is still loading in your vLLM version. Record the probe results alongside the /metrics data you already collect, so that failures can be traced to startup, memory pressure or the upstream itself.
Mapping client credentials and routes to upstream containers
This table maps each public route to its credential, upstream group, backing containers and monitoring path, so you can see what clients reach and what stays internal. Read each row as a rule your Nginx configuration must enforce, and confirm the exact route list against the vLLM version you run because endpoint sets change between releases.
| Route or component | Exposure and credential | Upstream and containers | Monitoring or confirmation |
|---|---|---|---|
| OpenAI-compatible inference (/v1/completions, /v1/chat/completions, /v1/embeddings) | Public to approved clients only; proxy forwards the client Authorization header and vLLM --api-key applies | Upstream group vllm_api with one entry per vLLM container on the Docker network | Confirm that --api-key covers these /v1 paths in your vLLM version |
| /v1/responses and audio endpoints | Allowlisted only if your applications call them; otherwise denied at Nginx | Same vllm_api group as inference routes | Confirm the path list against the online serving docs for your release |
| /invocations, /pause, /resume, /abort_requests | Denied at Nginx for all clients; not covered by --api-key | Reachable only from inside the Docker network or the admin host, if at all | Confirm which of these exist in your vLLM version before writing deny rules |
| /health (container liveness) | Not exposed to end users; checked by Nginx upstream probes or the orchestrator | Each container checked individually, not through the balanced group | Confirm the probe method your Nginx build supports, such as active health checks |
| /metrics (Prometheus scrape) | Denied on the public listener; scraped on a separate internal port or network | Scraper targets each vLLM container directly, bypassing the balanced group | Confirm scrape targets and that no proxy route exposes /metrics |
| Client keys and proxy headers | Per-client keys checked at Nginx where the gateway layer supports it; vLLM key stays set as a second check | Forwarded identity header is set by Nginx only, never trusted from the client | Confirm header names and key storage with your own security review |
Hardening the proxy and the container network
The Nginx layer is the only place users reach, so it decides which vLLM paths exist for callers. The cards below cover the proxy allowlist, the control endpoints that must stay private, encryption, API keys on the containers, network isolation and logging.
Allowlist only the user paths
Configure Nginx to forward only the /v1 routes that applications call, such as /v1/completions, /v1/chat/completions, /v1/responses and /v1/embeddings, and return 404 for everything else. The vLLM security guidance recommends a proxy that allowlists user-facing endpoints because the --api-key option does not cover every path. Check the allowlist after each vLLM upgrade, since new routes can appear in a release and would be exposed by default if you proxy by prefix only.
vLLM security docsKeep control endpoints off the public listener
Endpoints such as /invocations, /pause, /resume, /abort_requests, /metrics and /health are not protected by --api-key. Serve them on an internal listener or a separate port that only monitoring and operators can reach, and confirm from outside the network that these paths return errors through the public address. Pause and abort endpoints can disrupt a running service, so treat them as operator tools rather than application APIs.
vLLM metrics docsTerminate TLS at the proxy
Terminate HTTPS at Nginx with certificates from your own certificate authority, and restrict protocol versions and cipher suites to what your security baseline requires. Traffic between Nginx and the vLLM containers stays on the private container network, so decide whether that segment also needs encryption. Ask your security team to confirm the policy, because API keys and prompts travel over every hop.
- Only user path prefix
- /v1
Set an API key on each container
Start every vLLM container with the --api-key option, so a request that bypasses Nginx still needs a valid key. Keep the key in a secret store or an environment file with restricted permissions, not in the Compose file committed to source control. Rotating the key requires restarting the containers, so plan that step with the proxy configuration change.
Isolate the container network
Attach vLLM containers to an internal Docker network with no published host ports, and expose only the Nginx container on the frontend network. Set the network as internal where your Docker version and design allow it. Multi-node vLLM traffic is insecure by default, without authorization or encryption, so if you split one deployment across hosts, the cross-host links must sit on an isolated network the vLLM security docs describe. Splitting nodes across hosts does not make this pattern safe for that traffic.
vLLM parallelism docsLog access and review it
Configure Nginx access logs to record the client address, path, status, upstream address and request time, and ship them to a log store your team reviews. Do not log request bodies or the Authorization header, because prompts can contain regulated data and keys would be exposed. Alert on spikes in 404 responses to blocked paths and on repeated 401 responses, since both can signal probing.
Common failures when balancing vLLM with Nginx
This table lists the failures most often seen when several vLLM containers sit behind Nginx, with the cause and fix for each tied to documented vLLM behavior. Read each row as symptom, then cause, then the change to make at the proxy or the container. The main takeaway is that most failures trace back to the proxy configuration rather than to the model itself.
| Failure | Cause | Fix |
|---|---|---|
| 404 on allowed paths after a route change | The Nginx location block was rewritten or the upstream path prefix changed, so requests no longer match the endpoints vLLM serves such as /v1/chat/completions | Test each allowlisted path against a single backend with curl after every change, and keep the location rules in version control |
| Requests reaching /metrics through the public listener | The --api-key option does not protect /metrics, /health, /pause, /resume, /abort_requests or /invocations, so a catch-all proxy location exposes them | Allowlist only the /v1 paths users need and return 403 for everything else, and scrape /metrics from an internal network or monitoring listener only |
| Uneven load across containers | Long streaming generations keep connections open, so round-robin sends new requests to a replica already busy with long decodes | Use the least_conn directive in the upstream block, and confirm per-replica load with the vLLM metrics for request counts and KV cache use |
| A container returns errors while the model loads | Nginx sends traffic to a replica that has started but has not finished loading model weights or passed its readiness check | Add a health check that targets a vLLM readiness signal, and use max_fails and fail_timeout so the proxy stops routing to a failing replica |
| Timeouts on long generations | Nginx default proxy_read_timeout is shorter than the time a large completion or reasoning-heavy request needs to finish | Raise proxy_read_timeout and proxy_send_timeout for the /v1 location only, and disable proxy buffering for streamed responses |
| Chat completions fail with a template error | The served model has no chat template and none was supplied with --chat-template, so the chat completions API cannot run even though the proxy routes it correctly | Confirm the model's tokenizer includes a chat template, or pass --chat-template to each container so every replica serves the same format |
Questions buyers ask about vLLM load balancing with Nginx
What drives the cost of running vLLM behind Nginx?
Your cost comes from GPU or accelerator capacity, the proxy host, the infrastructure around them, and the people who operate the stack. vLLM itself has no paid edition and is licensed under Apache-2.0, so no vLLM license fee is part of the budget. GPU capacity usually dominates and recurs every month if you rent it, or is a capital purchase if you own it. Nginx has a free open-source edition, so the proxy cost is mainly the host and the engineering time to configure and monitor it. Ask any partner to separate one-time build work from recurring operations work in the quote.
Does vLLM cost money to license?
No. vLLM has no paid edition, and its GitHub repository lists the project under Apache-2.0. Your spending goes to accelerators, the surrounding infrastructure, implementation and the people who run it. Licensing questions for the proxy and any monitoring tools should be checked separately against each project's own license file, since they are separate components with their own terms.
How long does a vLLM load balancing build take?
The duration depends on how many vLLM containers you run, how many hosts and GPUs are already provisioned, how much of the model cache and network design is settled, and how many failure and allowlisting tests you require. A small pool on hosts you already run is much shorter than a build that also needs new GPU hosts and a shared cache design. No fixed duration applies to every environment, so ask for a timeline that lists each dependency and who is responsible for it.
What must our team provide before the build starts?
Plan to provide the Docker hosts and GPUs, administrative access to them, and a model source that the hosts can reach. You also need network rules that define which subnets can reach the Nginx listener, which can reach each vLLM container, and how the containers reach a shared model cache. Name the owner for TLS certificates and for DNS. Clear answers to these items at the start prevent most schedule slips.
Can an internal team set this up without a partner?
Yes, if the team has Docker, Nginx and GPU operations experience and time to test failure cases. The hard parts are not the first configuration file. They are verifying least-connection behavior under real load, confirming that Nginx marks a failing backend as down, keeping the model cache consistent across containers, and writing an allowlist that blocks /invocations, /pause, /resume, /abort_requests, /metrics and /health from users. The vLLM security documentation recommends a reverse proxy with an allowlist for this reason, so a team without a security reviewer should plan for that review.
How does Nginx detect a failed vLLM container?
Nginx uses passive health checks on the open-source edition: it marks an upstream as failed after a configured number of errors or timeouts within a window, then retries other upstreams. Active health checks are a separate feature whose availability depends on your Nginx edition and build, so confirm that before you depend on it. Because a vLLM container can be healthy at the process level but out of GPU memory, set timeouts that match your longest expected generation and test the behavior with a deliberately stopped container.
When is Kubernetes or a gateway like LiteLLM the better next step?
Move up a layer when you need automated restarts and scaling across many nodes, multi-node model sharding, or per-team keys, budgets and rate limits. The vLLM documentation lists Kubernetes options including the vLLM production-stack, KServe and LeaderWorkerSet. A gateway such as LiteLLM handles keys, budgets and fallback across deployments, which Nginx does not provide on its own. Stay with Nginx while the pool is a handful of Docker hosts, one team controls access and your operations staff can run the containers directly.
How a client request reaches a vLLM container through Nginx
The request starts at a client application that calls the public Nginx listener over TLS, where the proxy checks the path against an allowlist of user-facing endpoints. Nginx then selects a vLLM container on one of the Docker hosts using least-connection balancing. The trust boundary sits at the public listener: everything behind it runs on the internal network. Metrics scraping and health probes use a separate internal-only path, and each vLLM container reads model weights from shared storage. Check that /metrics and the operator endpoints never appear on the public side.
Public listener on the left, internal containers and metrics path on the right.
How DeployOpen works on this
DeployOpen plans and builds the Nginx layer in front of your vLLM containers inside your own infrastructure, then hands over the configuration, runbooks and tests your team needs to operate it. Engagements are fixed-scope, with the endpoints, failure behavior and evidence agreed in writing before any build work starts.
How we scope
- We confirm the Docker hosts, GPU capacity and number of vLLM containers you plan to run behind Nginx.
- We list which vLLM endpoints users may reach, since the proxy allowlist is the main control for /metrics and /health.
- We agree the written scope, deliverables and timeline with you before work starts, and document what is out of scope.
How we build
- We configure least-connection upstreams, health checks and timeouts sized for long-running model responses.
- We set up the shared model cache location and confirm each container reads the same model files without conflicts.
- We test failure detection by stopping containers and checking traffic moves to healthy backends and back again.
How we hand over
- You receive the Nginx configuration, container definitions and allowlist rules, with the reasons for each setting.
- You receive runbooks covering adding or removing a backend, rotating keys and recovering from a failed container.
- You receive test results and the evidence your security and compliance reviewers ask for about the serving path.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after handover.
- Retainers can cover reviewing the allowlist when vLLM releases change endpoint behavior or new routes appear.
- Each change to the proxy or backends can be retested against the agreed scope before it reaches production.

