In docker-compose.yml
, you usually specify a port mapping:
...
wiki:
image: requarks/wiki:2
depends_on:
- db
restart: unless-stopped
volumes:
- backups:/wiki/backups
ports:
- "3000:3000"
...
This means that the port 3000 in the docker container corresponds to the port 3000 on the server localhost.
Then, Caddy is used to reverse proxy all the requests from a specified subdomain on port 443 (https) to that port on the server local loop:
wiki.example.com {
reverse_proxy 127.0.0.1:3000
}
That's it, this is all you have to do!
/etc/caddy/Caddyfile
example.com {
root * /var/www/
file_server
}
serv1.example.com {
reverse_proxy 127.0.0.1:5020
}
serv2.example.com {
reverse_proxy 127.0.0.1:4080
}
serv3.example.com {
reverse_proxy 127.0.0.1:8050
}
If you modify the file, you need to reload it with
sudo caddy reload
in the terminal from the /etc/caddy/ directory.