proxy

package module
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: MIT Imports: 8 Imported by: 1

README

proxy_ip_parser

X-Forwarded-*, Forwarded, True-Client-IP, X-Real-Ip parser http middleware.

Description

When proxy is trusted, the leftmost IP address will be used as a RemoteAddr. Otherwise RemoteAddr won't be changed.

Usage
http:
  address: 127.0.0.1:12811
  max_request_size: 1024
  middleware: [ "proxy_ip_parser" ] <------ Middleware
  uploads:
    forbid: [ ".php", ".exe", ".bat" ]
  trusted_subnets: <----- Trusted addresses in CIDR format
    [
      "10.0.0.0/8",
      "127.0.0.0/8",
      "172.16.0.0/12",
      "192.168.0.0/16",
      "::1/128",
      "fc00::/7",
      "fe80::/10"
    ]
  pool:
    num_workers: 2
    max_jobs: 0
    allocate_timeout: 60s
    destroy_timeout: 60s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cidrs

type Cidrs []*net.IPNet

Cidrs is a slice of IPNet addresses

type Config

type Config struct {
	// TrustedSubnets declare IP subnets which are allowed to set ip using X-Real-Ip and X-Forwarded-For
	TrustedSubnets []string `mapstructure:"trusted_subnets"`
}

type Configurer

type Configurer interface {
	// UnmarshalKey takes a single key and unmarshal it into a Struct.
	UnmarshalKey(name string, out any) error

	// Has checks if config section exists.
	Has(name string) bool
}

type Plugin

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

func (*Plugin) Init

func (p *Plugin) Init(cfg Configurer, l *zap.Logger) error

func (*Plugin) Middleware

func (p *Plugin) Middleware(next http.Handler) http.Handler

func (*Plugin) Name

func (p *Plugin) Name() string

Jump to

Keyboard shortcuts

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