All Projects → tomMoulard → htransformation

tomMoulard / htransformation

Licence: MIT license
A Traefik plugin to change on the fly header's value of a request

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to htransformation

traefik-ondemand-plugin
Traefik plugin to scale containers on demand
Stars: ✭ 149 (+238.64%)
Mutual labels:  traefik, traefik-plugin
souin
An HTTP cache system, RFC compliant, compatible with @TykTechnologies, @traefik, @caddyserver, @go-chi, @bnkamalesh, @beego, @devfeel, @labstack, @gofiber, @go-goyave, @gin-gonic, @zalando, @zeromicro, @nginx and @apache
Stars: ✭ 269 (+511.36%)
Mutual labels:  traefik, traefik-plugin
traefik-private-plugins
Automatic patch for Traefik supporting private plugins
Stars: ✭ 21 (-52.27%)
Mutual labels:  traefik, traefik-plugin
plugin-rewritebody
No description or website provided.
Stars: ✭ 33 (-25%)
Mutual labels:  traefik, traefik-plugin
Fb Automated Birthday Wisher
Automatically wishes your selected fb friends on their Birthday
Stars: ✭ 39 (-11.36%)
Mutual labels:  hackathon
tape-recorder
BSV Hackathon: Use Tape Recorder to record any computation onto Bitcoin Script using a Wang B machine written in Forth
Stars: ✭ 22 (-50%)
Mutual labels:  hackathon
nebula
Source Code for the Home Server setup.
Stars: ✭ 48 (+9.09%)
Mutual labels:  traefik
hackathon-board
node.js based webapp to manage Hackathon events
Stars: ✭ 18 (-59.09%)
Mutual labels:  hackathon
nomad-demo
Vagrant based demo setup for running Hashicorp Nomad
Stars: ✭ 88 (+100%)
Mutual labels:  traefik
ci-hackathon-app
A community-built Django app to help automate future Code Institute hackathon events for students and alumni.
Stars: ✭ 13 (-70.45%)
Mutual labels:  hackathon
MultiDexArbBot
This is an arbitrage bot that uses existing price aggregators such as 1inch, Paraswap, dex.ag, matcha and more to get the best exchange rates across different decentralized exchanges on different blockchains and ecosystems.
Stars: ✭ 67 (+52.27%)
Mutual labels:  hackathon
design-kit-hackathon
My recommended list of design resources for any hackathon!
Stars: ✭ 19 (-56.82%)
Mutual labels:  hackathon
simple-traefik-dash
Zero conf service dashboard for Traefik v2 Ingress Controller
Stars: ✭ 36 (-18.18%)
Mutual labels:  traefik
GeoBlock
Traefik middleware plugin - Deny requests based on country of origin
Stars: ✭ 28 (-36.36%)
Mutual labels:  traefik-plugin
home-assistant-addons
Alex's Home Assistant Add-ons
Stars: ✭ 28 (-36.36%)
Mutual labels:  traefik
kmp-web-wizard
Wizard for Kotlin Multiplatform
Stars: ✭ 164 (+272.73%)
Mutual labels:  hackathon
docker-box
A lightweight docker application platform for single servers.
Stars: ✭ 62 (+40.91%)
Mutual labels:  traefik
traefik-extra-service-fabric
Traefik extra: Service Fabric Provider
Stars: ✭ 13 (-70.45%)
Mutual labels:  traefik
nodejs-hackathon-boilerplate-starter-kit
Just a Hackaton/Startup Full-stack node.js starter
Stars: ✭ 37 (-15.91%)
Mutual labels:  hackathon
ketos
Cross Container Builder (Ketos), a tasting project for Go Hackathon 2017 Shanghai. This project aims to help you building a docker image in CI platform better.
Stars: ✭ 20 (-54.55%)
Mutual labels:  hackathon

Header transformation plugin for traefik

Build Status

This plugin allows changing on the fly, the header value of a request.

Dev traefik.yml configuration file for traefik

pilot:
  token: [REDACTED]

experimental:
  devPlugin:
    goPath: /home/tm/go
    moduleName: github.com/tomMoulard/htransformation

entryPoints:
  http:
    address: ":8000"
    forwardedHeaders:
      insecure: true

api:
  dashboard: true
  insecure: true

providers:
  file:
    filename: rules-htransformation.yaml

How to dev

$ docker run -d --network host containous/whoami -port 5000
# traefik --config-file traefik.yml

How to use

To choose a Rule you have to fill the Type 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 the Name field

Rename

A Rule Rename needs two arguments.

  • Header, the regex of the header you want to replace
  • Value, 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: 0
X-Traefik-date: mer. 21 oct. 2020 11:57:39 CEST
# New header:
X-Traefik-merged: 0 # A value from old headers

Set

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 create
  • Value, the value of the new header
# Example Join
- Rule:
      Name: 'Set Cache-Control'
      Header: 'Cache-Control'
      Value: 'Foo'
      Type: 'Join'
# New header:
Cache-Control: Foo

Delete

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'

Join

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 join
  • Values, a list of values to add to the existing header
  • Sep, 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 in Value or one of the Values by setting an additional argument HeaderPrefix. Example:

# Example Usage
- Rule:
  Name: 'Header set'
  Header: 'X-Forwarded-For'
  HeaderPrefix: "^"
  Values:
      - 'Foo'
      - '^CF-Connecting-IP'
  Type: 'Join'
# Old header:
X-Forwarded-For: 1.1.1.1
CF-Connecting-IP: 2.2.2.2
# New headers:
CF-Connecting-IP: 2.2.2.2
X-Forwarded-For: Foo, 1.1.1.1

RewriteValue Rule

A RewriteValue Rule will replace the values of the headers identified by a matching regex with the provided value.

It needs 2 arguments

  • Header, the header or regex identifying the headers you want to change
  • Value, the new value of the headers
# 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

Careful

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 header X-Custom-2 to 'True', then delete it and set it again but with False

Authors

Tom Moulard Clément David Martin Huvelle Alexandre Bossut-Lasry
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].