You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Caddy automatically provisions TLS certificates for you. In order to make use of this awesome feature, do the following:
Ensure your server has ports 80 and 443 open
Have a DNS record pointed to your server for the domain you wish to obtain a certificate for (e.g. app.example.org -> <IP address>)
Export the env var for the domain you wish to use:
export DOMAIN=app.example.org
Start the docker compose stack:
docker compose up --build
Navigate to your domain and enjoy your easy TLS setup with Caddy! -> https://app.example.org
Extra Info 📚
Here is some extra info about the setup
Volumes 🛢️
The docker compose file creates two volumes:
./data/caddy_data:/data
./data/caddy_config:/config
The config volume is used to mount Caddy configuration
The data volume is used to store certificate information. This is really important so that you are not re-requesting TLS certs each time you start your container. Doing so can cause you to hit Let's Encrypt rate limits that will prevent you from provisioning certificates.
Environment Variables 📝
If you run the stack without the DOMAIN variable set in your environment, the stack will default to using localhost. This is ideal for testing out the stack locally.
If you set the DOMAIN variable, Caddy will attempt to provision a certificate for that domain. In order to do so, you will need DNS records pointed to that domain and you will need need traffic to access your server via port 80 and 443.
Disclaimer
This repo is extremely simple on purpose. You should tailor this to your needs if you plan on adapting it for production usage of any kind.
That being said, I will admit that I am currently running this setup (fastapi swapped for nodejs stack because the API was already written in JS) in production and it is working great for me. I'm just running this docker compose stack on a 2vCPU/4GB memory VM in Azure and its handling traffic just fine. Here is a 30 day snapshot of general metrics for this setup:
About
Quickly deploy Caddy to serve requests with FastAPI using docker-compose!