I’m running caddy inside a docker network with other services which are API for most of them.
I have a custom ssl certificate et the corresponding private key from Cloudflare I would like to use.
I also use Cloudflare DNS.
Unfortunately, Caddy keeps using port 2015 which seems to indicate that the ssl certificate wasn’t used.
Edit: A lot of people are finding this in search results, but be aware that this is about Caddy 1, which is discontinued. Caddy 2 does not have any default ports, per-se.
Caddy’s default port is 2015. When automatic HTTPS is activated, it changes any qualifying, unspecified ports to 443 for you (and 80 for the redirects to HTTPS).
Automatic HTTPS is not activated when you provide your own certificates, hence why Caddy is still binding to port 2015 in your case. If you provide your own certificates, then HTTPS is not managed/automatic, so you will have to set up redirects: Caddy doesn’t want to step on your configuration.
You might consider, instead of using this method, configuring Caddy specifically to listen on HTTP and HTTPS default ports by specifying the scheme for each site.