caddy_ip_list

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

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

Go to latest
Published: Feb 14, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

README

Caddy-IP-List Module

This module retrieves an IP list from specified URLs at a defined interval. It is designed to integrate with other modules like dynamic_client_ip or trusted_proxy in Caddy.

Supported from Caddy v2.6.3 onwards.

Example Configuration

Using dynamic_client_ip

You can get dynamic_client_ip from here

@denied dynamic_client_ip list {
    url https://www.cloudflare.com/ips-v4  # specify the URL to fetch the IP list
    url https://www.cloudflare.com/ips-v6  # You can use multiple URLs
    interval 12h
    timeout 15s
}
abort @denied
Using trusted_proxy
trusted_proxies list {
    url https://www.cloudflare.com/ips-v4  # specify the URL to fetch the IP list
    url https://www.cloudflare.com/ips-v6  # You can use multiple URLs
    interval 12h
    timeout 15s
}

Defaults

Name Description Type Default
url URL(s) to retrieve the IP list string required
interval Frequency at which the IP list is retrieved duration 1h
timeout Maximum time to wait for a response from the URL duration no timeout

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type URLIPRange

type URLIPRange struct {
	// List of URLs to fetch the IP ranges from.
	URLs []string `json:"url"`
	// refresh Interval
	Interval caddy.Duration `json:"interval,omitempty"`
	// request Timeout
	Timeout caddy.Duration `json:"timeout,omitempty"`
	// contains filtered or unexported fields
}

URLIPRange provides a range of IP address prefixes (CIDRs) retrieved from url.

func (URLIPRange) CaddyModule

func (URLIPRange) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*URLIPRange) GetIPRanges

func (s *URLIPRange) GetIPRanges(_ *http.Request) []netip.Prefix

func (*URLIPRange) Provision

func (s *URLIPRange) Provision(ctx caddy.Context) error

func (*URLIPRange) UnmarshalCaddyfile

func (m *URLIPRange) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile implements caddyfile.Unmarshaler.

list {
   interval val
   timeout val
   url string
}

Jump to

Keyboard shortcuts

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