traefik_dynamic_redirects

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

README

Traefik Plugin Bulk Redirects

release report OpenSSF Scorecard Coverage Status license

A Traefik middleware plugin for Cloudflare-style bulk redirects. It allows defining multiple redirects in a single Traefik Middleware configuration. This plugin supports exact redirects, subpath redirects, query string preservation, and configurable redirect status codes.

Redirect fields

Key Description
sourceURL absolute source URL to match
targetURL absolute redirect destination URL
statusCode redirect status code: 301, 302, 303, 307, 308
preserveQueryString enabled appends the original query string to the target URL
subpathMatching enabled matches the source path and all child paths below it

Configuration

Example usage

apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
  name: bulk-redirects
spec:
  plugin:
    bulkRedirects:
      redirects:
      - sourceURL: https://example.com/premium/coupon
        targetURL: https://example.com/en/premium/
        statusCode: 302
        preserveQueryString: enabled
        subpathMatching: disabled
      - sourceURL: https://example.com/docs
        targetURL: https://example.com/en/resources
        statusCode: 301
        preserveQueryString: enabled
        subpathMatching: enabled

Static configuration

experimental:
  plugins:
    bulkRedirects:
      moduleName: github.com/doodlescheduling/traefik-dynamic-redirects
      version: v0.0.1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, next http.Handler, config *Config, name string) (http.Handler, error)

Types

type Config

type Config struct {
	Redirects []Redirect `json:"redirects,omitempty"`
}

func CreateConfig

func CreateConfig() *Config

type DynamicRedirects

type DynamicRedirects struct {
	// contains filtered or unexported fields
}

func (*DynamicRedirects) ServeHTTP

func (dynamicRedirects *DynamicRedirects) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type Redirect

type Redirect struct {
	SourceURL           string            `json:"sourceURL,omitempty"`
	StatusCode          int               `json:"statusCode,omitempty"`
	PreserveQueryString string            `json:"preserveQueryString,omitempty"`
	AuthenticatedCookie string            `json:"authenticatedCookie,omitempty"`
	AuthenticatedTarget string            `json:"authenticatedTarget,omitempty"`
	LocaleCookie        string            `json:"localeCookie,omitempty"`
	DefaultTarget       string            `json:"defaultTarget,omitempty"`
	LocaleTargets       map[string]string `json:"localeTargets,omitempty"`
}

type RuntimeRedirect

type RuntimeRedirect struct {
	StatusCode          int
	PreserveQueryString string
	AuthenticatedCookie string
	AuthenticatedTarget string
	LocaleCookie        string
	DefaultTarget       string
	LocaleTargets       map[string]string
}

type Target

type Target struct {
	URL                 string
	StatusCode          int
	PreserveQueryString string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL