acl

package module
v0.0.0-...-4f9f690 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

README

Caddy ACL

Access Control Lists middleware for Caddy. Allows to limit access of locations to certain client addresses.

Syntax

acl paths... {
	allow	<subnet|ip>
	deny	<subnet|ip>
	status	<code>
	header	<name>
}
  • paths...: list of space separated locations to which apply ACL rules.
  • allow: subnet or IP to explicitly allow to access paths.
  • block: subnet or IP to explicitly deny from accessing paths.
  • status: respond with the given code when denying a request. Defaults to 403.
  • header: use the given header to get the client IP address. It always looks for X-Forwarded-For.

Denied subnets and IPs are checked first. If allow is used, only subnets and addresses explicitly allowed will be accepted. Otherwise only addresses explicitly denied will be rejected. Two options only make sense when deny is used: header and status. Multiple acl blocks can be used.

Examples

Only allow a given subnet (192.168.42.0/24) to access all files in /private:

acl /private {
	allow 192.168.42.0/24
}

Allow 192.168.42.0/24 to access to /private and /kikoo, but deny access to 192.168.42.15:

acl /private /kikoo {
	allow 192.168.42.0/24
	deny 192.168.42.15
}

Deny only 2 subnets and one address from accessing /private:

acl /private {
	deny 192.168.42.0/24
	deny 10.10.52.0/27
	deny 192.168.0.2
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ACL

type ACL struct {
	Next   httpserver.Handler
	Config []ACLBlockConfig
}

func (ACL) ServeHTTP

func (self ACL) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)

type ACLBlockConfig

type ACLBlockConfig struct {
	Paths  []string
	Allow  []*net.IPNet
	Deny   []*net.IPNet
	Status int
	Header string
}

describe one acl{} configuration block

Jump to

Keyboard shortcuts

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