dynamic_ip_matcher

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

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

Go to latest
Published: Oct 7, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

README

Dynamic Remote IP matcher for Caddy

Maintenance Go Reference GoReportCard example GitHub

The dynamic_remote_ip module is a clone of the remote_ip matcher with one key difference: instead of providing IP ranges upfront, you specify an IPRangeSource. This allows IP ranges to be dynamically loaded per request.

This module is based on the caddy-dynamic-clientip module by tuzzmaniandevil.

Installation

Build Caddy using xcaddy:

xcaddy build --with github.com/lanrat/caddy-dynamic-remoteip

Usage

:8880 {
    @denied dynamic_remote_ip my_dynamic_provider
    abort @denied

    reverse_proxy localhost:8080
}

Example using the built-in static provider (But why though?)

:8880 {
    @denied dynamic_remote_ip static 12.34.56.0/24 1200:ab00::/32
    abort @denied

    reverse_proxy localhost:8080
}

Development

Before diving into development, make sure to follow the Extending Caddy guide. This ensures you're familiar with the Caddy development process and that your environment is set up correctly.

To run Caddy with this module:

xcaddy run

License

The project is licensed under the Apache License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MatchDynamicRemoteIP

type MatchDynamicRemoteIP struct {
	// A module which provides a source of IP ranges, from which
	// requests are matched.
	ProvidersRaw json.RawMessage         `json:"providers,omitempty" caddy:"namespace=http.ip_sources inline_key=source"`
	Providers    caddyhttp.IPRangeSource `json:"-"`
	// contains filtered or unexported fields
}

MatchDynamicRemoteIP matchers the requests by the remote IP address. The IP ranges are provided by modules to allow for dynamic ranges.

func (MatchDynamicRemoteIP) CaddyModule

func (MatchDynamicRemoteIP) CaddyModule() caddy.ModuleInfo

func (MatchDynamicRemoteIP) Match

func (m MatchDynamicRemoteIP) Match(r *http.Request) bool

func (*MatchDynamicRemoteIP) Provision

func (m *MatchDynamicRemoteIP) Provision(ctx caddy.Context) error

func (*MatchDynamicRemoteIP) UnmarshalCaddyfile

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

Jump to

Keyboard shortcuts

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