header_based_proxy

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

Traefik Header Based Proxy Plugin

Overview

This plugin extends the functionality of Traefik, a modern reverse proxy and load balancer for microservices. Traefik provides automatic discovery of services, dynamic configuration, and flexible routing capabilities.

The Traefik Header Based Proxy Plugin enhances these features by offering a redirection option based on header values.

Features

  • Filter based on reqquest headers: Make a proxy redirect based on the value of specified header keys.

Usage

You have to install the plugin in the traefik definition like:

Ex: Using Docker Labels:

  • 'traefik.http.middlewares.my-proxy.plugin.proxy.Header=X-Header-Custom'
  • 'traefik.http.middlewares.my-proxy.plugin.proxy.Mapping.value1=https://service1'
  • 'traefik.http.middlewares.my-proxy.plugin.proxy.Mapping.value2=https://service2'
  • "traefik.http.routers.my-router.middlewares=my-proxy"

Contributing

We welcome contributions from the community to enhance the functionality and usability of the Traefik Public Plugin. If you'd like to contribute, please follow these guidelines:

  • Fork the Repository: Create your own fork of the repository to make changes.
  • Create a Branch: Create a new branch for your changes and work on them independently.
  • Submit a Pull Request: Once your changes are ready, submit a pull request to merge them into the main repository.
  • Follow Coding Standards: Adhere to coding standards, conventions, and best practices to maintain code quality.

License

The Traefik Header Based Proxy Plugin is released under the Apache 2 Licence.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

New creates a new CustomProxy plugin instance

Types

type Config

type Config struct {
	Header  string            `json:"header,omitempty"`  // target header
	Mapping map[string]string `json:"mapping,omitempty"` // mapping pairs (regex, target service)
}

Config defines the plugin configuration.

func CreateConfig

func CreateConfig() *Config

CreateConfig creates the default plugin configuration.

type CustomProxy

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

CustomProxy defines the proxy struct

func (*CustomProxy) ServeHTTP

func (a *CustomProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Process the requests to verify if they match with defined mapping patterns

Jump to

Keyboard shortcuts

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