Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: interface conversion: interface {} is nil, not *caddyhttp.Server #52

Closed
cloudwindy opened this issue May 31, 2022 · 10 comments
Closed

Comments

@cloudwindy
Copy link

panic: interface conversion: interface {} is nil, not *caddyhttp.Server

goroutine 55 [running]:
github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy.(*Handler).reverseProxy(0xc000124300, {0x7fdfc555d1b0, 0xc000690090}, 0xc00025fb00, 0xc00025fa00, 0xc00037ed40, {0xc00003b500, {0x1a32780, 0x3}, {0xc00003ff20, ...}, ...}, ...)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/reverseproxy/reverseproxy.go:730 +0x189d
github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy.(*Handler).proxyLoopIteration(0xc000124300, 0xc00025fb00, 0x1?, {0x7fdfc555d1b0, 0xc000690090}, {0x0, 0x0}, {0xc09dab3606b7f048, 0x1bf03c58, 0x2a16ec0}, ...)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/reverseproxy/reverseproxy.go:526 +0xf30
github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy.(*Handler).ServeHTTP(0xc000124300, {0x7fdfc555d1b0, 0xc000690090}, 0xc00025fa00, {0x1db0ac0, 0x1b4b6b8})
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/reverseproxy/reverseproxy.go:435 +0x3a5
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*metricsInstrumentedHandler).ServeHTTP(0xc0000ae700, {0x1db9e58?, 0xc00048dcc0}, 0xc00025fa00, {0x1db0ac0, 0x1b4b6b8})
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/metrics.go:132 +0x53b
github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1({0x1db9e58?, 0xc00048dcc0?}, 0x1782a01?)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/routes.go:272 +0x3b
github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0xc0004c9920?, {0x1db9e58?, 0xc00048dcc0?}, 0xc0003a8af0?)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/caddyhttp.go:57 +0x2f
github.com/sillygod/cdp-cache.(*Handler).fetchUpstream.func1(0xc00025f700, 0xc000125200?)
	github.com/sillygod/[email protected]/handler.go:124 +0x3dd
created by github.com/sillygod/cdp-cache.(*Handler).fetchUpstream
	github.com/sillygod/[email protected]/handler.go:103 +0x25e
@cloudwindy
Copy link
Author

Caddyfile:

http_cache {
	cache_type file 
	path /data/cache
	match_path /
	match_header Content-Type image/vnd.microsoft.icon text/js text/css image/gif image/jpeg image/png
}

Dockerfile:

FROM caddy:builder AS builder

RUN xcaddy build \
    --with github.com/kirsch33/realip \
    --with github.com/sillygod/cdp-cache

FROM caddy:latest

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

@cloudwindy
Copy link
Author

The problem was that I was building from the latest version of caddy.

@cloudwindy
Copy link
Author

Let's keep this open as this won't work with v2.5.1.

@cloudwindy cloudwindy reopened this May 31, 2022
@sillygod
Copy link
Owner

sillygod commented Jun 2, 2022

Let's keep this open as this won't work with v2.5.1.

Thanks for noting this package is not compatible with the caddy v2.5.1.

However, keeping updated with the latest version of caddy is not in high priority! It may be upgraded someday.

@tve
Copy link

tve commented Oct 10, 2022

I hit the same issue. Is it realty that much work to update? From a usage point of view it's the difference between being able to just download a caddy binary with the cdp-cache module vs. having to set-up a whole compilation environment...

@PythonLinks
Copy link
Contributor

I made so many failed attempts to compile it. I am not a go developer. Kind of delayed my caching by 9 months Did not have much traffic, so was not a hot issue.

With Bastille containers, I got it compiling really quickly. Created a container, installed some tools, and then downloaded the go executable. It was so easy. When I got it wrong, I just deleted the container and repeated. I could not do that with my regular development environment.

In fact I would be happy to publish my Bastille container, if anyone is interested.

There is a larger problem at work here. You will see that the cache-handler software is under the auspices of /caddy-server. It supports distributed caches.

The cdp-cache is kind of abandoned. Lives on a less famous location. Not updated since April 8th. Requires an old version of Go and an old version of caddy.

Even though it is much simpler, and the docs are much much better.

My take away is that open source goes where the money is. Large companies that need distributed caches. Which is different from the needs of small companies, that just run on a single server.

I see the same issue everywhere. The needs of big and small companies are different. Here is my article about the difference between Docker and bsd. "Docker is for big companies, Bastille BSD is for small companies and developers. "

https://forestwiki.com/bastille-vs-docker

@tve
Copy link

tve commented Oct 10, 2022

Just as a heads-up, building caddy is not that easy... To install xcaddy I had to use:

go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest

And I built caddy:

xcaddy build v2.4.1 --with github.com/sillygod/cdp-cache

But just running the executable to get help:

/h/s/caddy> ./caddy                                                                                 
panic: qtls.CertificateRequestInfo doesn't match                                                    
                                                                                                    
goroutine 1 [running]:                                                                              
github.com/marten-seemann/qtls-go1-16.init.0()                                                      
        github.com/marten-seemann/[email protected]/unsafe.go:17 +0x198                            

From caddyserver/caddy#4118 I gather I have to use an older version of Go, perhaps...

@PythonLinks
Copy link
Contributor

Yes, you have to use go 1.17
I had huge problems with the builds. Mostly because I am not a go developer. And I did not want to cause trouble in my development environment.

I submitted a read me pull request, and offered to make more edits, but have not heard back about the existing changes I made, so not much point investing a lot more effort into it.

Hopefully eventually they will respond to it.

@korniychuk
Copy link

For now, I managed to build this extension with Go v1.17 (MacOS).
xcaddy build v2.4.6 --with github.com/sillygod/cdp-cache

@sillygod
Copy link
Owner

cdp-cache is upgraded (#67 ) so close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants