Search code examples
caddycaddyfile

Specify Caddy listening port


"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.)


Solution

  • 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