Closed unamedplayer closed 3 years ago
Meow? :\
Hi @unamedplayer,
Did you add the middleware on a router ?
Here is a full configuration sample of how using and combining pilot plugins, I hope it will help you:
traefik.toml:
[entryPoints]
[entryPoints.web]
address = ":10080"
[api]
insecure = true
[providers]
[providers.file]
directory = "/dynamic_conf.d"
watch = true
[pilot]
token = "xxxx"
[experimental.plugins.rewritebody]
modulename = "github.com/traefik/plugin-rewritebody"
version = "v0.3.1"
[experimental.plugins.cache]
modulename = "github.com/traefik/plugin-simplecache"
version = "v0.2.1"
dynamic_conf.d/test_plugins.toml:
[http.routers]
[http.routers.my-router]
rule = "PathPrefix(`/`)"
middlewares = ["testHeader", "rewrite-foo", "my-cache"]
service = "my-service"
entryPoints = ["web"]
[http.middlewares]
[http.middlewares.rewrite-foo.plugin.rewritebody]
lastModified = true
[[http.middlewares.rewrite-foo.plugin.rewritebody.rewrites]]
regex = "panique"
replacement = "stress"
[http.middlewares.testHeader.headers]
[http.middlewares.testHeader.headers.customRequestHeaders]
Host = "www.perdu.com"
[http.middlewares.my-cache.plugin.cache]
path = "/tmp/cache/"
[http.services]
[http.services.my-service]
[http.services.my-service.loadBalancer]
[[http.services.my-service.loadBalancer.servers]]
url = "http://www.perdu.com"
Then when you test you can see that each plugin is doing its job:
$ curl http://127.0.0.1:10080 -v
* Trying 127.0.0.1:10080...
* Connected to 127.0.0.1 (127.0.0.1) port 10080 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:10080
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Cache-Control: max-age=600
< Cache-Status: miss
< Content-Type: text/html
< Date: Thu, 04 Feb 2021 06:32:36 GMT
< Etag: "cc-5344555136fe9-gzip"
< Expires: Thu, 04 Feb 2021 06:42:36 GMT
< Last-Modified: Thu, 02 Jun 2016 06:01:08 GMT
< Server: Apache
< Vary: Accept-Encoding,User-Agent
< Content-Length: 203
<
<html><head><title>Vous Etes Perdu ?</title></head><body><h1>Perdu sur l'Internet ?</h1><h2>Pas de stress, on va vous aider</h2><strong><pre> * <----- vous êtes ici</pre></strong></body></html>
* Connection #0 to host 127.0.0.1 left intact
$ ls /tmp/cache/
70
$ curl http://127.0.0.1:10080 -v
* Trying 127.0.0.1:10080...
* Connected to 127.0.0.1 (127.0.0.1) port 10080 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:10080
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Cache-Control: max-age=600
< Cache-Status: hit
< Content-Type: text/html
< Date: Thu, 04 Feb 2021 06:32:36 GMT
< Etag: "cc-5344555136fe9-gzip"
< Expires: Thu, 04 Feb 2021 06:42:36 GMT
< Last-Modified: Thu, 02 Jun 2016 06:01:08 GMT
< Server: Apache
< Vary: Accept-Encoding,User-Agent
< Content-Length: 203
<
<html><head><title>Vous Etes Perdu ?</title></head><body><h1>Perdu sur l'Internet ?</h1><h2>Pas de stress, on va vous aider</h2><strong><pre> * <----- vous êtes ici</pre></strong></body></html>
* Connection #0 to host 127.0.0.1 left intact
Rémi
Did you add the middleware on a router ?
That's exactly what I was missing :) I didn't find that anywhere else. Merci mille fois for pointing it out.
And on a fun note, I grew up in France, in the early days of the Internet, back when finding a silly website was novel and you couldn't believe someone would spend money on a domain just for one silly joke. For as long as I can remember, I've been using perdu.com for all my web testing needs. I chuckle to think about our distinct trajectories in life, yet, probably because we shared the same culture at the same time, we both adopted perdu.com as our website of reference for this. I shit you not, I have my reference perdu.com traefik reverse SSL proxy config just like you do.
J'ai beaucoup perdu de mon Français mais j'adore l'idée d'une expèrience partagée il y a plus de 20 ans qui nous amène tous les deux ajourd'hui a utiliser ce site :).
Bref, that's a long diatribe for a silly website :) but it made my day that you used it for this. And well it also made my day that you nailed my problem in your first sentence. Merci encore!
Just in case it's useful, the middleware still shows up funny in the Traefik Dashboard, but it works!
Take care!
Well, I'm at a loss, I launch traefik with:
I confirmed it loaded:
DEBU[2021-01-23T05:11:46Z] loading of plugin: cache: github.com/traefik/plugin-simplecache@v0.2.1
but when I try to use it in a static config with:
I end up with an odd type-less middleware:
and the middleware isn't in effect in the router:
I've tried everything I could think of, hence my cry for help :) Any feedback or ideas very much appreciated, thank you!