Redirect
is a Traefik plugin to redirect a list with status code.
Based on :
Into Traefik static configuration
[entryPoints]
[entryPoints.web]
address = ":80"
[pilot]
token = "xxxxxxxxx"
[experimental.plugins]
[experimental.plugins.traefik-plugin-redirect]
moduleName = "github.com/evolves-fr/traefik-plugin-redirect"
version = "v1.0.0"
entryPoints:
web:
address: :80
pilot:
token: xxxxxxxxx
experimental:
plugins:
traefik-plugin-redirect:
moduleName: "github.com/evolves-fr/traefik-plugin-redirect"
version: "v1.0.0"
--entryPoints.web.address=:80
--pilot.token=xxxxxxxxx
--experimental.plugins.traefik-plugin-redirect.modulename=github.com/evolves-fr/traefik-plugin-redirect
--experimental.plugins.traefik-plugin-redirect.version=v1.0.0
Into Traefik dynamic configuration
labels:
- "traefik.http.middlewares.my-redirect.plugin.redirect.redirects[0].regex=/301"
- "traefik.http.middlewares.my-redirect.plugin.redirect.redirects[0].replacement=/moved-permanently"
- "traefik.http.middlewares.my-redirect.plugin.redirect.redirects[0].statusCode=301"
- "traefik.http.middlewares.my-redirect.plugin.redirect.redirects[1].regex=/not-found"
- "traefik.http.middlewares.my-redirect.plugin.redirect.redirects[1].statusCode=404"
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: my-redirect
spec:
plugin:
traefik-plugin-redirect:
redirects:
- regex: /301
replacement: /moved-permanently
statusCode: 301
- regex: /not-found
statusCode: 404
[http]
[http.middlewares]
[http.middlewares.my-redirect]
[http.middlewares.my-redirect.plugin]
[[http.middlewares.my-redirect.plugin.traefik-plugin-redirect.redirects]]
regex = "/redirect"
replacement = "/ok"
statusCode = "302"
[[http.middlewares.my-redirect.plugin.traefik-plugin-redirect.redirects]]
regex = "^/gone$"
statusCode = "410"
[[http.middlewares.my-redirect.plugin.traefik-plugin-redirect.redirects]]
regex = "^/not-found$"
statusCode = "404"
http:
middlewares:
my-redirect:
plugin:
traefik-plugin-redirect:
redirects:
- regex: /301
replacement: /moved-permanently
statusCode: 301
- regex: /not-found
statusCode: 404