Caddy v2.2.1 似乎不尊重给定地址的端口Caddyfile
:
myfinedomain.com:9999 {
respond "Nothing to see here. Srsly."
}
启动 caddy 只会导致以下错误(取自日志):
{"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
因此,caddy 似乎尝试绑定到端口 80,这是不应该的。
该文档将端口列为地址的有效选项。
对这里可能缺少的东西的想法表示赞赏。
这是导致解释发生了什么的线索:
查找此内容可以解释 Caddy自动尝试将 HTTP 重定向到 HTTPS 并管理 TLS 证书,除非在各种情况下,例如用户明确禁用该功能。
如果您不打算运行 HTTPS 网站,则应明确禁用此功能,或考虑使用不同的 Web 服务器。