layer4

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

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

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 11 Imported by: 0

README

layer4

The layer4 Caddyfile (via global options) for mholt/caddy-l4.

Currently supported handlers:

  • echo (layer4.handlers.echo)
  • proxy_protocol (layer4.handlers.proxy_protocol)
  • proxy (layer4.handlers.proxy)
  • tls (layer4.handlers.tls)

Installation

$ xcaddy build --with github.com/RussellLuo/caddy-ext/layer4

Caddyfile Syntax

The layer4 global option
layer4 {
    # server 1
    <listens...> {
        <handler>
        ...
    }

    # server 2
    <listens...> {
        <handler>
        ...
    }
}
Handlers

The echo handler:

echo

The proxy_protocol handler:

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

The proxy handler:

proxy [<upstreams...>] {
    # backends
    to <upstreams...>
    ...

    # load balancing
    lb_policy       <name> [<options...>]
    lb_try_duration <duration>
    lb_try_interval <interval>

    # active health checking
    health_port     <port>
    health_interval <interval>
    health_timeout  <duration>
    
    # sending the PROXY protocol
    proxy_protocol <version>
}

The tls handler:

tls

Example

With the following Caddyfile:

{
    layer4 {
        :8080 {
            proxy {
                to localhost:8081 localhost:8082
                lb_policy round_robin
                health_interval 5s
            }
        }
    }
}

:8081 {
    respond "This is 8081"
}

:8082 {
    respond "This is 8082"
}

Requests to :8080 will be forwarded to upstreams :8081 and :8082 in a round-robin policy:

$ curl http://localhost:8080
This is 8081
$ curl http://localhost:8080
This is 8082

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnmarshalL4ProxySelectionCaddyfile

func UnmarshalL4ProxySelectionCaddyfile(inst caddy.Module, d *caddyfile.Dispenser) error

func UnmarshalL4proxySelectionModule

func UnmarshalL4proxySelectionModule(d *caddyfile.Dispenser, moduleID string) (caddy.Module, error)

UnmarshalL4proxySelectionModule is like `caddyfile.UnmarshalModule`, but for l4proxy's selection modules, which do not implement `caddyfile.Unmarshaler` yet.

Types

This section is empty.

Jump to

Keyboard shortcuts

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