https://github.com/virtualzone/rewriteheaders
Rewrite HTTP Response Headers.
https://github.com/virtualzone/rewriteheaders
traefik-plugin
Last synced: 11 months ago
JSON representation
Rewrite HTTP Response Headers.
- Host: GitHub
- URL: https://github.com/virtualzone/rewriteheaders
- Owner: virtualzone
- License: apache-2.0
- Created: 2022-02-20T13:15:37.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-20T16:18:15.000Z (over 4 years ago)
- Last Synced: 2025-07-19T07:27:43.755Z (11 months ago)
- Topics: traefik-plugin
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Rewrite Header
Rewrite Headers is a middleware plugin for [Traefik](https://traefik.io) which replaces HTTP response headers using regular expressions.
Based on: https://github.com/vincentinttsh/rewriteheaders
## Configuration
### Static
```yaml
pilot:
token: "xxxx"
experimental:
plugins:
rewriteHeaders:
modulename: "github.com/virtualzone/rewriteheaders"
version: "v0.1.0"
```
### Dynamic
To configure the Rewrite Headers plugin, create a [middleware](https://docs.traefik.io/middlewares/overview/) in your dynamic configuration as explained [here](https://docs.traefik.io/middlewares/overview/).
The following example creates and uses the rewriteHeaders middleware plugin to modify the Location HTTP response header.
```yaml
http:
routes:
my-router:
rule: "Host(`localhost`)"
service: "my-service"
middlewares :
- "rewriteHeaders"
services:
my-service:
loadBalancer:
servers:
- url: "http://127.0.0.1"
middlewares:
rewriteHeaders:
plugin:
rewriteHeaders:
rewrites:
- header: "Location"
regex: "^http://(.+)$"
replacement: "https://$1"
```