Caddy 总是尝试绑定到端口 80,无论 Caddyfile 中的地址是什么

Caddy 总是尝试绑定到端口 80,无论 Caddyfile 中的地址是什么

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,而它不应该这样做。

文档列出端口作为地址的有效选项。

对于这里可能缺少什么,我们深表感谢。

答案1

以下是解释发生了什么事情的线索:

{"level":"info","ts":1614778157.9213488,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}

查找这个可以解释 Caddy自动地尝试将 HTTP 重定向到 HTTPS 并管理 TLS 证书,但用户明确禁用功能。

如果您不打算运行 HTTPS 网站,您应该明确禁用此功能,或考虑使用其他 Web 服务器。

相关内容