pteich / caddy-tlsconsul

🔒 Consul K/V storage for Caddy Web Server / Certmagic TLS data
Apache License 2.0
98 stars 18 forks source link

Empty ClusterPluginConstructor in plugin registration #5

Closed mswart closed 5 years ago

mswart commented 5 years ago

I was excited to find this plugin and tried it out. As this plugin is currently not available via the official downloader I registered it in caddy/caddymain/main.go and compiled caddy. Once I started caddy with activated consul storage plugin it crashes during startup:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8241dc]
goroutine 1 [running]:
github.com/mholt/caddy/caddytls.NewConfig(0xc420120300, 0xc42017f750, 0xc420036cf0, 0x24)
        /home/mswart/go/src/github.com/mholt/caddy/caddytls/config.go:117 +0x58c
github.com/mholt/caddy/caddyhttp/httpserver.(*httpContext).InspectServerBlocks(0xc420216150, 0x7ffccdf69e20, 0x14, 0xc42019b660, 0x1, 0x1, 0xc42019b660, 0x1, 0x1, 0x0, ...)
        /home/mswart/go/src/github.com/mholt/caddy/caddyhttp/httpserver/plugin.go:193 +0x5a8
github.com/mholt/caddy.ValidateAndExecuteDirectives(0xdb2de0, 0xc4201fa2c0, 0xc420120300, 0xc420120300, 0x1, 0xc42000c5f0)
        /home/mswart/go/src/github.com/mholt/caddy/caddy.go:609 +0x2c6
github.com/mholt/caddy.startWithListenerFds(0xdb2de0, 0xc4201fa2c0, 0xc420120300, 0x0, 0x0, 0x0)
        /home/mswart/go/src/github.com/mholt/caddy/caddy.go:517 +0x126
github.com/mholt/caddy.Start(0xdb2de0, 0xc4201fa2c0, 0xdb2de0, 0xc4201fa2c0, 0x0)
        /home/mswart/go/src/github.com/mholt/caddy/caddy.go:474 +0xf6
github.com/mholt/caddy/caddy/caddymain.Run()
        /home/mswart/go/src/github.com/mholt/caddy/caddy/caddymain/run.go:184 +0x404
main.main()
        src/github.com/mholt/caddy/caddy/main.go:27 +0x27

The null pointer appears to be the result of calling RegisterClusterPlugin with an uninitialized variable and not a function. Experiments to use NewConsulStorage or some variation of such a function were unsuccessful (go type/interface mismatch during compilation).

How do I compile and use this plugin correctly? Thx.

pteich commented 5 years ago

I’ll have a look into this. Reason is probably that these parts of Caddy still change until the new version is released.

pteich commented 5 years ago

@mswart I finally got a working version with Go 1.12 by cloning my plugin into Caddy vendor folder at the right place and enable the plugin in ./caddy/caddymain/run.go Have a look at the Dockerfile that now does exactly this. (You can use the Docker image pteich/caddy-tlsconsul:latest)

mswart commented 5 years ago

Cloning the plugin into the vendor directory of caddy did the trick. Thx.

pteich commented 5 years ago

After the current transition of Caddy to Go modules this hack is no longer necessary.