vLLM with HTTPS: Self-Host an LLM Behind a Caddy Reverse Proxy

Andreas Nigg
Andreas Nigg · Co-Founder, Pondhouse Data
Published Updated 7 min read
vLLM with HTTPS: Self-Host an LLM Behind a Caddy Reverse Proxy
On this page

To run your own LLM securely over HTTPS, serve the model with vLLM and put the Caddy web server in front of it as a reverse proxy. vLLM is a fast, open-source inference server with an OpenAI-compatible API. It can serve HTTPS if you give it certificate files, but it doesn't obtain or renew certificates. Caddy does both automatically. This guide sets up both in Docker, step by step.

Why self-host at all? Trusted platforms like Microsoft Azure offer LLMs as a service under generally well-regarded security and privacy policies. For some applications, though, a self-hosted LLM is a must. It gives you complete control over your data and the flexibility to adapt the model to your requirements.

vLLM is known for its excellent inference performance: high throughput at reasonable cost. As we'll see, it's also very easy to set up. Running a state-of-the-art open-source model is a single command away.

The part many people skip is HTTPS encryption. They're happy to run their own models but don't encrypt the data channel, which ironically makes their data less secure than with off-the-shelf AI services. Caddy fixes that. It's a web server designed to be easy to use and secure by default.

This guide covers installing vLLM, configuring Caddy and connecting the two to enable HTTPS. It assumes you're comfortable running commands in a terminal.

Prerequisites

Before we begin, you will need to have the following:

  • A server with a public IP address
  • Optional: For best performance, your server should be equipped with a GPU
  • A domain name. The domain name points to the public IP address of the server
  • The server has docker installed

General strategy for running your LLM with HTTPS

Running your own LLM over HTTPS requires three main components:

  1. The model itself
  2. An inference server that handles requests to the model. You could invoke the model directly, but an inference server provides a web API and, more importantly, uses optimizations that allow parallel requests and faster response times.
  3. A web server that handles the HTTPS encryption and forwards requests to the inference server. You could access the inference server directly. vLLM can even serve HTTPS itself (--ssl-certfile and --ssl-keyfile), but then you have to obtain the certificates and renew them every few months yourself. A reverse proxy does that for you, and the inference server never has to listen on a public port.

In this guide, vLLM is the inference server that serves the model, and Caddy is the web server. We run vLLM in a Docker container and Caddy as a reverse proxy in front of it. Caddy handles the HTTPS encryption and forwards requests to vLLM.

What is vLLM?

vLLM is a high-performance, open-source inference server for large language models. It is designed to be easy to use and to provide high throughput. In the vLLM team's launch post from June 2023, vLLM reached up to 24x the throughput of Hugging Face Transformers (HF) and up to 3.5x that of Text Generation Inference (TGI). In the chart below (LLaMA-13B on an A100-40GB GPU), vLLM handles 154.2 requests per minute, against 61.8 for TGI and 6.4 for HF.

vLLM throughput vs. HF and TGI for LLaMA-13B on A100-40GB

vLLM offers the following advantages:

  • Integration with popular Hugging Face models
  • High-throughput serving with various decoding algorithms, including parallel sampling, beam search, and more
  • Tensor parallelism support for distributed inference
  • Streaming outputs
  • Support for NVIDIA GPUs and AMD GPUs
  • OpenAI-compatible API server

The last point is especially interesting: vLLM offers the same API as OpenAI, so you can use the same client libraries and tools you would use with OpenAI's models.

What is Caddy?

Caddy is a web server designed to be easy to use and secure by default. It generates and renews SSL certificates automatically and has no external dependencies. Caddy is also known for its stability and performance.

Preparation: install the NVIDIA Container Toolkit

vLLM requires a GPU to run. Since we deploy via Docker, we need a GPU-aware Docker runtime, like the NVIDIA container toolkit.

To install the NVIDIA Container Toolkit, run the following commands:

1curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
2 && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
3 sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
4 sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
5sudo apt-get update
6sudo apt-get install -y nvidia-container-toolkit
7sudo nvidia-ctk runtime configure --runtime=docker
8sudo systemctl restart docker

Step 1: Run vLLM in a Docker container

Note: When we wrote this, vLLM didn't support Arm-based Macs. It now has experimental CPU support for Apple Silicon if you build it from source, but the Docker setup in this guide needs an NVIDIA GPU. vLLM works great on consumer GPUs like an NVIDIA 3080 or 3090.

Deploying vLLM is almost too easy to deserve its own blog post. Launch the vLLM Docker container, define the model to serve, done.

The following models are currently supported: vLLM model support

We create a new Docker network for the vLLM server, so the Caddy server can run in the same network and talk to vLLM.

1docker network create vllmnetwork
2docker run --runtime nvidia --gpus all \
3 -v ~/.cache/huggingface:/root/.cache/huggingface \
4 -p 127.0.0.1:8000:8000 \
5 --ipc=host \
6 --network=vllmnetwork \
7 --name vllm-server \
8 -d \
9 vllm/vllm-openai:latest \
10 --model TheBloke/Mistral-7B-OpenOrca-GPTQ

You can use either the ipc=host flag or the --shm-size flag to let the container access the host's shared memory. vLLM uses PyTorch, which uses shared memory to share data between processes under the hood, particularly for tensor parallel inference.

This command starts the vLLM server and exposes it on port 8000, bound to 127.0.0.1 only. That way you can test it from the server itself, but the unencrypted port isn't reachable from outside; external traffic goes through Caddy, which reaches vLLM over the Docker network. It downloads and serves the model specified in the model parameter automatically. Mistral-7B-OpenOrca is a model from 2023; newer models from the supported list run with the same command. You can now send POST requests to the server at http://localhost:8000. Test it with a simple request:

1curl http://localhost:8000/v1/completions \
2 -H "Content-Type: application/json" \
3 -d '{
4 "model": "TheBloke/Mistral-7B-OpenOrca-GPTQ",
5 "prompt": "San Francisco is a",
6 "max_tokens": 20,
7 "temperature": 0.1
8 }'

Important: A vLLM server serves one base model (plus optional LoRA adapters). The request therefore needs to name the model the server was started with. To serve several models, run one container per model and route between them, as the vLLM FAQ suggests.

Step 2: Install Caddy as an HTTPS reverse proxy

With the inference server running, we need a secure way to connect to it. Caddy handles the HTTPS encryption and forwards requests to the inference server.

Specifically, we run a Caddy web server in Docker and forward all requests arriving on port 443 to port 8000, with the port 443 connection secured by HTTPS certificates. This takes two things: a Caddyfile with the Caddy configuration, and the Caddy server running as a Docker container.

Create a Caddyfile

The Caddyfile tells Caddy how to handle incoming requests. Ours forwards all requests from port 443 to the internal vLLM service on port 8000. Caddy handles the HTTPS certificates for you.

Here's the example Caddyfile configuration:

1
2https://yourdomain.com {
3 reverse_proxy vllm-server:8000
4 }

Replace yourdomain.com with your actual domain name. This configuration tells Caddy to listen for HTTPS connections for yourdomain.com and forward those requests to port 8000 of the vllm-server container.

Run Caddy

Now we run the Caddy server as a Docker container. We mount the Caddyfile into the container and expose it on port 443. To persist the automatically created SSL certificates, we create two volumes, caddy_data and caddy_config, mapped to the /data and /config directories of the Caddy container.

1docker run -d \
2 -p 443:443 \
3 -v /path/to/Caddyfile:/etc/caddy/Caddyfile \
4 -v caddy_data:/data \
5 -v caddy_config:/config \
6 --network vllmnetwork \
7 caddy

Additional notes

  • Caddy will automatically obtain and renew SSL certificates for your domain using Let's Encrypt, provided your domain is correctly pointed to the server running Caddy.
  • Ensure your server's firewall and security groups (if any) allow traffic on port 443.

Conclusion

You now have a self-hosted LLM that's reachable over HTTPS: vLLM serves the model in a Docker container, and Caddy terminates HTTPS with automatic Let's Encrypt certificates and forwards requests to vLLM over a shared Docker network. Because vLLM's API is OpenAI-compatible, you can point existing OpenAI clients or a chat front end like Open WebUI or LibreChat at your domain. For running a larger reasoning model on your own hardware, see our guide to DeepSeek R1 with SGLang.

If you are planning a self-hosted LLM or chat application for your company, we build these setups as part of our AI consulting work.

Further reading

Interested in building high-quality AI agent systems?

We prepared a comprehensive guide based on cutting-edge research for how to build robust, reliable AI agent systems that actually work in production. This guide covers:

  • Understanding the 14 systematic failure modes in multi-agent systems
  • Evidence-based best practices for agent design
  • Structured communication protocols and verification mechanisms
Andreas Nigg

About the author

Andreas Nigg

Co-Founder, Pondhouse Data

Andreas has spent more than eight years building data applications. At Pondhouse Data he designs and ships AI systems and integrates them into complex, real-world environments.