caddygoproxyproto

package module
v0.0.0-...-ca2f7a8 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: MIT Imports: 5 Imported by: 0

README

caddy-go-proxyproto

Caddy wrapper for go-proxyproto

This repository is forked from rocketreferrals and adds Caddyfile support.

caddy listener wrapper go_proxyproto for Caddy 2 adds support for PROXY headers using the go proxy proto listener https://github.com/pires/go-proxyproto

This caddy plugin makes it possible to listen to AWS NLB Proxy Protocol V2 requests. The official proxy protocol package referenced on the caddy documentation does not handle AWS NLB requests well. This is the only way to preserve client IP addresses when putting caddy behind a NLB on AWS.

Caddyfile

Load the listener before the tls wrapper in the global config section of your Caddyfile

{
    servers {
      listener_wrappers {
        go_proxyproto {
          timeout 5s
        }
        tls
      }
    }
    ...
}
JSON

Load the listener before the tls wrapper

{
  "apps": {
    "http": {
      "servers": {
        "myserver": {
          // ...
          "listener_wrappers":[{"wrapper": "go_proxyproto", "timeout": "5s"}, {"wrapper":"tls"}]
          // ...
        }
      }
    }
  }
}
Installation

This is an example Dockerfile to build a caddy 2.4.6 Docker image containing this plugin.

FROM caddy:2.4.6-builder AS builder

RUN xcaddy build \
    --with github.com/Jelle7/caddy-go-proxyproto

FROM caddy:2.4.6

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

This image can now be ran on an EC2 instance/EKS cluster behind an NLB and pass client IP addresses correctly in the X-Forwarded-For header field.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Wrapper

type Wrapper struct {
	Timeout caddy.Duration `json:"timeout,omitempty"`
}

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

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