1. The problem I’m having:
I have two dockerized hobby projects which both use Caddy.
I’d like to host these all on one VPS to keep my costs low. They work when running them alone, but both use port 443 so can’t run them at the same time.
I was thinking of adding one “global/proxy” Caddy container to recieve :443 traffic and proxy the requests based on domain names to correct “hobby/sub-” Caddy containers.
Something like this:
domain1.com {
??? hobby_caddy1:8443
}
domain2.com {
??? hobby_caddy2:9443
}
I’d like to have the hobby projects’ Caddy container to handle the tls/cert and for the “global” Caddy to just proxy.
I’m not sure how to achieve this, e.g. how to set up this proxy Caddy or is there a better solution?
2. Error messages and/or full log output:
(no error yet, just want to know how to do it)
3. Caddy version:
v2.7.5
4. How I installed and ran Caddy:
Using official caddy image and running with docker-compose up.
a. System environment:
I’m using docker compose on a Ubuntu VPS
How my hobby projects look:
# docker-compose.yml
version: "3.8"
services:
hobby_app:
expose: 9000
networks:
- hobby_network
...
hobby_caddy:
image: caddy
ports:
- 80:80
- 443:443
volumes:
- ./caddy/data/:/data/
- ./caddy/config/:/config/
- ./Caddyfile:/etc/caddy/Caddyfile
networks:
- hobby_network
b. Command:
I run the project with simple
docker-compose up -d
d. My complete Caddy config:
My hobby projects’ Caddyfile
domain1.com {
reverse_proxy hobby_app:9000
}