Specify Caddy listening port

NtlX picture NtlX · Jul 6, 2018 · Viewed 8.8k times · Source

"By default, Caddy will bind to ports 80 and 443 to serve HTTPS and redirect HTTP to HTTPS." (https://caddyserver.com/docs/automatic-https)

How can we change this port?

Background: In our setup, Caddy runs behind an AWS load balancer which forwards requests from port 443 to port 4443. Therefore, we would like to have Caddy listen on 4443. (We use the DNS challenge.)

Answer

Jens picture Jens · Jul 6, 2018

According to the documentation:

The first line of the Caddyfile is always the address of the site to serve.

In your Caddyfile:

<domain>:<port>

Example:

localhost:8080