Is it possible to write a custom TCP middleware?

I would like to write a middleware to inspect a binary protocol which is passed through a traefik load-balancer and which would close the connection if certain conditions are met. It seems writing a custom middleware is the way to go.

I have read the plugin development and the demo plugin pages, and browsed the Plugin Catalogue, but I can only find info on how to make a HTTP middleware. The plugin demo page writes that a middlware plugin provides a http.Handler and does not mention a TCP handler or similar.

Is it possible to develop a middleware for TCP and are there any examples?

Thanks,
Kurt

Hey @kurt-hectic , currently plugins are only supported for HTTP routers, we'll revisit this in the future while evaluating use cases for TCP and UDP as well.

thanks for the info.

My use case is to check whether the username in the MQTT protocol corresponds to the Subject Alternative Name of the (client side) SSL certificate used to secure the connection. Traefik terminates the SSL connection but passes through the MQTT connection to a downstream MQTT server.

1 Like

My use case is to support EDNS0 ECS for TCP/UDP requests so downstream DNS servers have information of the originating client ip address. (It's the equivalent of X-Forwarded-For but for DNS)

I wanted to write a middleware to add this EDNS0 header to the TCP and UDP packets, so middleware support for tcp/udp would be nice :slight_smile: