caddy2proxyprotocol

package module
v0.0.2-forest Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

Add PROXY protocol support to Caddy 2

proxy_protocol is a listener wrapper for Caddy 2 that adds support for PROXY headers on new connections.

Configuration

Options
Name Type Default Description
timeout duration 5s Specifies the maximum time for the PROXY header to be received. If zero, timeout is disabled.
allow []string 0.0.0.0\0 A list of CIDR ranges to allow/require PROXY headers from.
JSON

The wrapper needs to be loaded BEFORE the tls wrapper.

{
  "apps": {
    "http": {
      "servers": {
        "myserver": {
          // ...
          "listener_wrappers":[
            {"wrapper": "proxy_protocol", "timeout": "5s", "allow": ["192.168.86/24"]},
            {"wrapper":"tls"}
          ]
          // ...
        }
      }
    }
  }
}
Caddyfile

The wrapper may be configured via global options in the Caddyfile.

{
  servers {
    listener_wrappers {
      proxy_protocol {
        timeout <duration>
        allow <cidrs...>
      }
      tls
    }
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Wrapper

type Wrapper struct {
	// Timeout specifies an optional maximum time for the PROXY header to be received. If zero, timeout is disabled. Default is 5s.
	Timeout caddy.Duration `json:"timeout,omitempty"`

	// Allow is an optional list of CIDR ranges to allow/require PROXY headers from.
	Allow []string `json:"allow,omitempty"`
	// contains filtered or unexported fields
}

Wrapper provides PROXY protocol support to Caddy by implementing the caddy.ListenerWrapper interface. It must be loaded before the `tls` listener.

func (Wrapper) CaddyModule

func (Wrapper) CaddyModule() caddy.ModuleInfo

func (*Wrapper) Provision

func (pp *Wrapper) Provision(ctx caddy.Context) error

func (*Wrapper) UnmarshalCaddyfile

func (w *Wrapper) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the listener wrapper from Caddyfile tokens. Syntax:

proxy_protocol {
    timeout <duration>
    allow <IPs...>
}

func (*Wrapper) WrapListener

func (pp *Wrapper) WrapListener(l net.Listener) net.Listener

Jump to

Keyboard shortcuts

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