abiosoft / caddy-docker

Docker container for Caddy
https://hub.docker.com/r/abiosoft/caddy/
MIT License
766 stars 314 forks source link

panic: runtime error: slice bounds out of range #211

Closed emarref closed 4 years ago

emarref commented 4 years ago

We are running caddy in a Kubernetes environment. The latest docker hub caddy update (1.0.2) has caused a panic, and our deployment never finishes. Caddy version 1.0.1 does not have this issue. This issue affects abiosoft/caddy from Docker Hub.

The error message we get is:

panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/caddyserver/caddy/caddyhttp/httpserver.Address.Key(...)
    /go/pkg/mod/github.com/caddyserver/caddy@v1.0.2/caddyhttp/httpserver/plugin.go:494
github.com/caddyserver/caddy/caddyhttp/httpserver.(*httpContext).InspectServerBlocks(0xc000144180, 0x7fff8bfd2550, 0xe, 0xc000135580, 0x1, 0x1, 0xc000135580, 0x1, 0x1, 0x0, ...)
    /go/pkg/mod/github.com/caddyserver/caddy@v1.0.2/caddyhttp/httpserver/plugin.go:143 +0x12ee
github.com/caddyserver/caddy.ValidateAndExecuteDirectives(0xe04020, 0xc000141040, 0xc00011a300, 0xc00011a300, 0x1, 0xc00000e600)
    /go/pkg/mod/github.com/caddyserver/caddy@v1.0.2/caddy.go:614 +0x3b7
github.com/caddyserver/caddy.startWithListenerFds(0xe04020, 0xc000141040, 0xc00011a300, 0x0, 0x0, 0x0)
    /go/pkg/mod/github.com/caddyserver/caddy@v1.0.2/caddy.go:516 +0x125
github.com/caddyserver/caddy.Start(0xe04020, 0xc000141040, 0xe04020, 0xc000141040, 0x0)
    /go/pkg/mod/github.com/caddyserver/caddy@v1.0.2/caddy.go:473 +0xea
github.com/caddyserver/caddy/caddy/caddymain.Run()
    /go/pkg/mod/github.com/caddyserver/caddy@v1.0.2/caddy/caddymain/run.go:193 +0x646
main.main()
    /caddy/main.go:13 +0x5d
exit status 2

With the following Caddyfile:

:80
tls off
root /var/empty
fastcgi / localhost:9000 php {
    root /var/www/public
}
andrewzah commented 4 years ago

Can confirm, we have the same issue. Caddyfile:

our.domain:80 {
}

our.domain:443 {
  tls self_signed

  proxy /api http://server:5000 {
    transparent
  }
}

internal.net:443 {
  tls server.crt server.key

  proxy /api http://server:5000 {
    transparent
  }
}
abiosoft commented 4 years ago

Looking into it. Kindly stick to 1.0.1 for now.

abiosoft commented 4 years ago

Looks related to this https://github.com/caddyserver/caddy/issues/2706

toabi commented 4 years ago

This change in the config files fixes the issue with 1.0.2 https://github.com/caddyserver/caddy/issues/2706#issuecomment-521232621

abiosoft commented 4 years ago

A release with a fix is imminent https://github.com/caddyserver/caddy/issues/2706#issuecomment-521324042.

emarref commented 4 years ago

Awesome thanks very much

abiosoft commented 4 years ago

Fixed upstream. Docker hub should have 1.0.3 in few hours when the builds are done.