Caddy v2.2.1 doesn't seem to respect the port of a given address in this Caddyfile
:
myfinedomain.com:9999 {
respond "Nothing to see here. Srsly."
}
Starting up caddy simply results in the following error (taken from the log):
{"level":"info","ts":1614777947.500496,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
{"level":"info","ts":1614777947.5004952,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc0002d2380"}
run: loading initial config: loading new config: http app module: start: tcp: listening on :80: listen tcp :80: bind: address already in use
start: caddy process exited with error: exit status 1
{"level":"info","ts":1614778157.9187949,"msg":"using provided configuration","config_file":"/usr/local/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
{"level":"info","ts":1614778157.9210048,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["[::1]:2019","127.0.0.1:2019","localhost:2019"]}
{"level":"info","ts":1614778157.9213488,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
{"level":"info","ts":1614778157.92195,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc0002be3f0"}
run: loading initial config: loading new config: http app module: start: tcp: listening on :80: listen tcp :80: bind: address already in use
start: caddy process exited with error: exit status 1
Thus, caddy seems to try binding to port 80, which it shouldn't do.
The documentation lists the port as being a valid option for addresses.
Ideas on what might be missing here are appreciated.
Here is the clue that leads to explaining what is going on:
Looking this up gives the explanation that Caddy automatically attempts to redirect HTTP to HTTPS and manage TLS certificates except in various circumstances, such as the user explicitly disabling the functionality.
If you do not intend to run an HTTPS web site, you should explicitly disable this functionality, or consider using a different web server.