-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
enable custom plugins/middlewares for Traefik #1336
Comments
@migueleliasweb thanks for the suggestion. That does sound like a pretty interesting idea. I haven't worked with Go's new plugin framework yet, so I can't judge on what it's like to work with it from a practical point of view. One concern I'm seeing is that right now, plugins are only supported on Linux. While this should probably not be too much of an issue when running Traefik in production (most people supposedly use Linux or Docker anyway), it's going to make development on any other platform much harder. You'd have to revert to tricks like running your builds off of a Docker container with the source code being bind-mounted in. I'm not saying that we shouldn't do it because of these restrictions, but that we have to make sure the development workflow is acceptably usable for people not running Linux natively. |
Hey @timoreimann ! I'm aware of the possible limitation since the Go plugin feature is still in it's early phase of development but soon I hope this feature will be released for all platforms and architectures. Just keep in mind this is a cool feature and this could lead a much faster development of modules and extra features for traefik from the community ;D. |
Full ACK, the potential is pretty huge. |
Plugins to transform request/response would be great! The ability to adjust headers (add/remove/edit) alone would go a long way. |
Is anybody working on this? Do we have a set of requirements? |
At my company we are considering several API gateways and this feature is a must have |
This comment has been minimized.
This comment has been minimized.
I would love to see some development of a WAF or fail2ban or some sort of DOS security from attackers. |
@tscibilia you can always install fail2ban on the host machine |
I am using caddy because it supports custom plugins. But I really like some of the features provided by traefik, it would be better if traefik could support custom plugins. |
This would be huge. I am thinking something between Apache Traffic Server and Proxygen but in Go. |
I'm willing to take a shot doing a transform request/response middleware, if there is some sort of requirements for it? I assume with the new middleware infrastructure, it should be relatively easy to do. Mostly i would assume what can be done in Microsoft IIS URL rewrite would be enough: Replacing using regexes, and their match groups. And considering that Go already has pretty good support for regexes, that should be relatively trivial. |
As far as I'm concerned one just needs to use the Go plugin support that was introduced in the compiler some time go. Plugins then should implement the Middleware interface that already exists in Traefik. The hard part is actually loading the plugins, discovering them and calling them. |
Native Go plugins have a lot of gotchas at the moment. We use them at work and had to come up with a whole lot of workarounds and our own toolchain around them. Just to list a few issues:
Points 3. and 4. have two implications:
Additionally, it is still unclear to me if the introduction of go modules would fix some of those issues or make them worse (mostly because I've been too scared to test). |
The Lua solution seems OK. Even if it adds a little latency, is an opt-in feature. I also think that is better to have a working solution rather than no solution at all, since a lot of people are asking for this feature. I have yet to test @negasus solution, but It looks great! Best case scenario would be to allow creating middlewares in both scripts (Lua) and webhooks (GRPC, HTTP). |
def would like this for integrating w./ something like modsecurity |
When we talk about plugins/middlewares, will it be possible for me to create a middleware that query a database and based on that information decides which backend to use? I would like to use traefik to determine which docker container to use depending on the client accessing. For example, client-1 would access application container v1.0 and client-2 would access v2.0, which way to go depending on the data stored in the database. Is there a workaround for that scenario currently? |
Here's one use-case for a middleware that has a lua solution for ngnix: Working around Safari's lack of client certificate support for websockets. Hopefully it would be possible to do with traefik's future plugin system:
https://blog.christophermullins.com/2017/04/30/securing-homeassistant-with-client-certificates |
@emilevauge Can you expand a bit on the plan you hinted at earlier? -^ Seems there are a few options:
|
There is Hashicorp gRPC based plugin system here |
@andrewsav-datacom #2362 |
@ldez ah, so you already know. |
as @dduportal didn't like my idea of having a dedicated issue #5591 to keep this one clean, let me allow to present you my proposal on how to move things forward before (if ever) a final, all-satisfying solution to introduce plugins can be found. IssueWe want to extend Traefik, but an all-agreed plugin system seems far away. That's why additional plugins can only be compiled with Traefik. As adding new plugins requires code changes of Traefik itself, it is hard to maintain them or for users to have several of those plugins merged together. ProposalRestructure Traefik, so additional Middlewares (defined as Go Modules) can be compiled alongside Traefik without having to touch Traefik's source files. This would allow to automate custom Traefik builds with a custom set of builtin Middlewares (e.g. the Lua one) even from different sources, and for Middleware developers to maintain their code independent of Traefik. Please see #5591 for additional (high-level) details. What do you think? |
I will try make grpc plugin for traefik2 just for fun. Its interesting |
Hello what can we do to have this feature added to traefik? Whathever the implementation is, to be able to execute a custom action from a middleware to interact with a request. Maybe some tests have been made with lua or go or grpc. The first use case I see for this kind of custom middleware is a WAF (i.e. calling mod security) which I admit I have no idea how it is pluggable. Thanks! |
Meanwhile i did update a repo https://github.com/negasus/traefik2-luascript for latest version of Traefik2 :) |
I saw that envoy supports web assembly extensions. Maybe it would be a good idea to use this instead language specific plugins (Go, Lua, etc.). There are some wasm VMs written in Go e.g. https://github.com/perlin-network/life |
one could even go a step further with WebAssembly packaged plugins similar to https://webassemblyhub.io/ |
currently using an open source api gateway that has the option of adding middlewares via go plugins built in: https://www.krakend.io/docs/extending/writing-plugins/ |
Latest new from containous on the topic: https://community.containo.us/t/custom-middleware-for-validating-jwt/5806/4?u=zespri |
After seeing the Go1.8 new plugin feature I though that this could help a lot o people to add specific functionalities to Traefik.
Instead of building/compiling/shipping a custom-made version of Traefik to enable a custom functionality it would be possible to write way simpler custom-made middlewares with this approach, doesn't it ?
Try imagine creating a package that receives the request at a parameter without having to recompile the whole Traefik repository just to add a small change. Does it sounds like a middleware ? Because for me it is ! It's just a go1.8-plugin-based-middleware !
What do you guys think ?
The text was updated successfully, but these errors were encountered: