/rewriteheaders

Rewrite HTTP Response Headers.

Primary LanguageGoApache License 2.0Apache-2.0

Rewrite Header

Rewrite Headers is a middleware plugin for Traefik which replaces HTTP response headers using regular expressions.

Based on: https://github.com/vincentinttsh/rewriteheaders

Configuration

Static

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 in your dynamic configuration as explained here. The following example creates and uses the rewriteHeaders middleware plugin to modify the Location HTTP response header.

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"