Is there a way to AddListenerMiddleware after tls.Listener?

Hi there,

1. My Caddy version (caddy version):

latest v2 branch

2. How I run Caddy:

Use go run command from source

System environment:


3. The problem I’m having:

I’d like to register a ListenerMiddleware after tls.Listener.

In v1 I could register my listener middleware, it works well in PlainHTTP.

But what I wanted is that it should work in Secure HTTP. I can’t reach that because my listener will be wrapped in tls.Listener.

What I can see in v2 is that I can implement a http.Handler module but it is not a listener I was looking for.

4. Why I need this feature

I’ve a specified protocol if it matches that, I want to handle this connection by my own. If not it will be considered as a HTTP request.

Thanks a lot

1 Like


This exact item is still on my shortlist before the v2 RCs. I hope to get around to it soon!

Thanks for your reply.

Just to be sure that can I add a listener in which wraps tls.Listener?

something like this

type moduleListener struct {
  net.Listener // which will be tls.Listener, if TLS was enabled

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.