Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/traefik/plugin-rewritebody
Rewrite body is a middleware plugin for Traefik which rewrites the HTTP response body by replacing a search regex by a replacement string
https://github.com/traefik/plugin-rewritebody
traefik traefik-plugin
Last synced: 4 days ago
JSON representation
Rewrite body is a middleware plugin for Traefik which rewrites the HTTP response body by replacing a search regex by a replacement string
- Host: GitHub
- URL: https://github.com/traefik/plugin-rewritebody
- Owner: traefik
- License: apache-2.0
- Created: 2020-07-07T07:49:47.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-07T02:02:08.000Z (over 2 years ago)
- Last Synced: 2024-11-03T18:34:10.563Z (10 days ago)
- Topics: traefik, traefik-plugin
- Language: Go
- Homepage: https://plugins.traefik.io/plugins/628c9ec2ffc0cd18356a97a2/log4-shell
- Size: 24.4 KB
- Stars: 56
- Watchers: 15
- Forks: 20
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rewrite Body
Rewrite body is a middleware plugin for [Traefik](https://github.com/traefik/traefik) which rewrites the HTTP response body by replacing a search regex by a replacement string.
## Configuration
### Static
```toml
[pilot]
token = "xxxx"[experimental.plugins.rewritebody]
modulename = "github.com/traefik/plugin-rewritebody"
version = "v0.3.1"
```### Dynamic
To configure the `Rewrite Body` plugin you should create a [middleware](https://doc.traefik.io/traefik/middlewares/overview/) in
your dynamic configuration as explained [here](https://doc.traefik.io/traefik/middlewares/overview/).
The following example creates and uses the `rewritebody` middleware plugin to replace all `foo` occurrences by `bar` in the HTTP response body.If you want to apply some limits on the response body, you can chain this middleware plugin with the [Buffering middleware](https://doc.traefik.io/traefik/middlewares/http/buffering/) from Traefik.
```toml
[http.routers]
[http.routers.my-router]
rule = "Host(`localhost`)"
middlewares = ["rewrite-foo"]
service = "my-service"[http.middlewares]
[http.middlewares.rewrite-foo.plugin.rewritebody]
# Keep Last-Modified header returned by the HTTP service.
# By default, the Last-Modified header is removed.
lastModified = true# Rewrites all "foo" occurences by "bar"
[[http.middlewares.rewrite-foo.plugin.rewritebody.rewrites]]
regex = "foo"
replacement = "bar"[http.services]
[http.services.my-service]
[http.services.my-service.loadBalancer]
[[http.services.my-service.loadBalancer.servers]]
url = "http://127.0.0.1"
```