Setting up the Caddy reverse proxy server in podman
This article is also part of my podman series.
Writing about setting up a Ghost blog does not seem complete without setting up a reverse proxy server. To complete my use case, I decided to use the Caddy reverse proxy. You can find out more about Caddy on their website. https://caddyserver.com
Step 1 - Update DNS records for the site
Ensure the DNS record related to the domain has been updated to the public IPv4 address of the hosting server. In my case, I added an A record.
A @ <Host IPv4 Public Address>
Step 2 - Update your internet provider modem and firewall
Your internet provider modem will need to be updated to forward ports 80 and 443 to your hosting server.
I also use a firewall behind my internet modem so I also had to create a firewall rule to allow the same ports (80,443) to be directed to my hosting server's internal IPv4 address.
Step 3 - Create a Caddyfile configuration file
Within my sites subdirectory, I created another directory called caddy. I then created an empty file called Caddyfile.
mkdir -p caddy
cd caddy
touch Caddyfile
Using your favourite editor, modify the file. I used these values for my setup.
# Your email for LetsEncrypt warnings/notices.
email <email address>
domain.site1.com {
reverse_proxy localhost:8081
}
domain.site2.com {
reverse_proxy localhost:8082
}
analytics.site.com {
reverse_proxy localhost:8083
}
Step 4 - Run Caddy
This time around, I ended up just using podman run instead of podman-compose.
Here is the command I used.
$ podman run -d \
--name caddy-server \
--restart=always \
-v ~/sites/caddy/Caddyfile:/etc/caddy/Caddyfile:Z
-p 80:80 \
-p 443:443 \
docker.io/caddy
The Ghost blog should now be accessible publicly on the internet. You can update the Caddyfile to add more sites.
Please refer to this site if you would like to know more about how to check if your Caddy setup is working or if you would like to find out more detailed technical information.

