Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork16
A Traefik plugin to change on the fly header's value of a request
License
tomMoulard/htransformation
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This plugin allows changing on the fly, the header value of a request.
$ docker compose up
To choose a Rule you have to fill theType
field with one of the following:
- 'Del' : to Delete a header
- 'Join' : to Join values on a header
- 'Rename' : to rename a header
- 'RewriteValueRule': to rewrite header values
- 'Set' : to Set a header
Each Rule can be named with theName
field.
Each Rule can also be configured to change headers on the request or theresponse by using theSetOnResponse
configuration.IfSetOnResponse
is set totrue
, the header will be changed on the response.Otherwise, it will be changed on the request.Its default value isfalse
.
A Rule Rename needs two arguments.
Header
, the regex of the header you want to replaceValue
, the new header
# Example Rename-Rule:Name:'Header rename'Header:'Cache-Control'Value:'NewHeader'Type:'Rename'
# Old header:Cache-Control:gzip, deflate# New header:NewHeader:gzip, deflate
-Rule:Name:'Header Renaming'Header:'X-Traefik-*'Value:'X-Traefik-merged'Type:'Rename'
# Old header:X-Traefik-uuid:0X-Traefik-date:mer. 21 oct. 2020 11:57:39 CEST# New header:X-Traefik-merged:0# A value from old headers
A Set rule will either create or replace the header and value (if it already exists)
A rule Set need 2 arguments
Header
, the header you want to createValue
, the value of the new header
# Example-Rule:Name:'Set Cache-Control'Header:'Cache-Control'Value:'Foo'Type:'Set'
# New header:Cache-Control:Foo
A rule Delete need one arguments
Header
, the header you want to delete
# Example Del-Rule:Name:'Delete Cache-Control'Header:'Cache-Control'Type:'Del'
A Join rule will concatenate the values of the existing header with the new one. If the header doesn't exist, it'll do nothing
It needs 3 arguments
Header
, the header you want to joinValues
, a list of values to add to the existing headerSep
, the separator you want to use
# Example Join-Rule:Name:'Header join'Header:'Cache-Control'Sep:','Values: -'Foo' -'Bar'Type:'Join'
# Old header:Cache-Control:gzip, deflate# Joined header:Cache-Control:gzip, deflate,Foo,Bar
You can reuse other header values inValue
or one of theValues
by setting an additional argumentHeaderPrefix
.Example:
# Example Usage-Rule:Name:'Header set'Header:'X-Forwarded-For'HeaderPrefix:"^"Sep:','Values: -'Foo' -'^CF-Connecting-IP'Type:'Join'
# Old header:X-Forwarded-For:1.1.1.1CF-Connecting-IP:2.2.2.2# New headers:X-Forwarded-For:1.1.1.1,Foo,2.2.2.2CF-Connecting-IP:2.2.2.2
A RewriteValue Rule will replaceall instances of the matching pattern in the values of the headers identified by a matching regex with the provided value. This works for multiple matches within a single header value (e.g., values separated by semicolons).
It needs 2 arguments
Header
, the header or regex identifying the headers you want to changeValue
, the regex pattern to match in the header valueValueReplace
, the replacement value (can use capture groups like$1
)
# Example RewriteValueRule-Rule:Name:'Header rewriteValue'Header:'Foo'Value:'X-(.*)'ValueReplace:'Y-$1'Type:'RewriteValueRule'
# Old header:Foo:X-Test# Modified header:Foo:Y-Test
# Example RewriteValueRule with multiple matches-Rule:Name:'Header rewriteValue multiple'Header:'Foo'Value:'X-(\\d+)-(\\w+)'ValueReplace:'Y-$2-$1'Type:'RewriteValueRule'
# Old header:Foo:X-12-Test;X-34-Prod# Modified header:Foo:Y-Test-12;Y-Prod-34
The rules will be evaluated in the order of definition
#Example-Rule:Name:'Header addition'Header:'X-Custom-2'Value:'True'Type:'Set'-Rule:Name:'Header deletion'Header:'X-Custom-2'Type:'Del'-Rule:Name:'Header join'Header:'X-Custom-2'Value:'False'Type:'Set'
Will set the headerX-Custom-2
to 'True', then delete it and set it again but withFalse
Tom Moulard | Clément David | Martin Huvelle | Alexandre Bossut-Lasry |
---|---|---|---|
![]() | ![]() | ![]() | ![]() |
About
A Traefik plugin to change on the fly header's value of a request
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Contributors10
Uh oh!
There was an error while loading.Please reload this page.