caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
57.51k stars 4.01k forks source link

Caddy V2 redir panic #2842

Closed sosodev closed 4 years ago

sosodev commented 4 years ago

Running into this with a pretty simple Caddyfile

www.domain.com {
    redir https://domain.com{uri}
}
domain.com {
    reverse_proxy / localhost:3000
}

The following stacktrace is produced when running Caddy V2 Beta 8 with ./caddy2_beta8_linux_amd64 run and navigating to www.domain.com

net/http.(*conn).serve.func1(0xc0002bc6e0)
    /usr/local/go/src/net/http/server.go:1767 +0x139
panic(0xcc2ae0, 0x151cdf0)
    /usr/local/go/src/runtime/panic.go:679 +0x1b2
go.uber.org/zap.(*Logger).clone(...)
    /Users/matt/Dev/pkg/mod/go.uber.org/zap@v1.10.0/logger.go:252
go.uber.org/zap.(*Logger).With(0x0, 0xc0001d7e00, 0x1, 0x1, 0xc0000f0d20)
    /Users/matt/Dev/pkg/mod/go.uber.org/zap@v1.10.0/logger.go:163 +0x45
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).ServeHTTP(0xc000189520, 0xf11d00, 0xc0000f0d20, 0xc000310b00)
    /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:86 +0x677
net/http.serverHandler.ServeHTTP(0xc0000f0460, 0xf11d00, 0xc0000f0d20, 0xc000310900)
    /usr/local/go/src/net/http/server.go:2802 +0xa4
net/http.(*conn).serve(0xc0002bc6e0, 0xf14980, 0xc0001d7cc0)
    /usr/local/go/src/net/http/server.go:1890 +0x875
created by net/http.(*Server).Serve
    /usr/local/go/src/net/http/server.go:2927 +0x38e
2019/10/30 03:05:49 http: panic serving [redacted]:34406: runtime error: invalid memory address or nil pointer dereference

However, when running beta 6 the redirect works as expected.

mholt commented 4 years ago

Thanks for the report! I cannot reproduce it...

Can you do me a favor and see how minimal you can make your Caddyfile before the problem goes away? (I am a little busy right at the moment, so this'll help speed things up.)

i.e. is it just the redir line that causes it?

Can you actually fill out the issue template, please?

sosodev commented 4 years ago

I actually can't reproduce it anymore since I rebooted my server either.. Must have been something finicky somewhere else in the stack. Sorry for wasting your time. :heart:

mholt commented 4 years ago

No worries, thanks for double-checking, I was having a slight panic over here since I'm pretty sure that was not a problem when I tested it 😅

mholt commented 4 years ago

@sosodev FWIW, we just fixed a very very similar looking bug here: https://github.com/caddyserver/caddy/issues/2849