combine

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 9 Imported by: 0

README

IP prefix combining module for Caddy

This module retrieves IP prefixes from other modules and combines them into a single list of IP prefixes for use in Caddy trusted_proxies directives.

NOTE: it doesn't actually merge adjacent or overlapping prefixes, it just puts all of the sub-results into a big list and returns that.

Example config

An example configuration you might use while experimenting with different ways to put your site behind Cloudflare:

trusted_proxies combine {
    # For access via Cloudflare directly, using github.com/WeidiDeng/caddy-cloudflare-ip
    cloudflare
    # For access using cloudflared container on the local Docker bridge network, using github.com/fvbommel/caddy-dns-ip-range
    dns cloudflared
}

This will trust both public Cloudflare IPs and the one cloudflared is "borrowing" on your internal network (assuming it's registered in the local DNS).

There are no other settings, though you can of course pass settings to each individual sub-directive:

trusted_proxies combine {
    cloudflare {
        interval 12h
        timeout 15s
    }
    dns cloudflared {
        interval 1m
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CombinedIPRange

type CombinedIPRange struct {
	// The IP ranges to combine.
	PartsRaw []json.RawMessage `json:"parts,omitempty" caddy:"namespace=http.ip_sources inline_key=source"`
	// contains filtered or unexported fields
}

This module combines the prefixes returned by several other IP source plugins. In a caddyfile, you can specify these in the block following the "combine" tag.

func (CombinedIPRange) CaddyModule

func (c CombinedIPRange) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*CombinedIPRange) GetIPRanges

func (c *CombinedIPRange) GetIPRanges(r *http.Request) (result []netip.Prefix)

func (*CombinedIPRange) Provision

func (c *CombinedIPRange) Provision(ctx caddy.Context) error

func (*CombinedIPRange) UnmarshalCaddyfile

func (c *CombinedIPRange) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile implements caddyfile.Unmarshaler.

An example configuration you might use while experimenting with different ways to put your site behind Cloudflare:

combine {
   # For access via Cloudflare directly, using github.com/WeidiDeng/caddy-cloudflare-ip
   cloudflare
   # For access using cloudflared container on the same Docker network, using github.com/fvbommel/caddy-dns-ip-range
   dns cloudflared
}

Jump to

Keyboard shortcuts

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