mirror

package module
v0.0.0-...-3384eb8 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

README

caddy-mirror

Caddy module for on-demand local mirroring/caching of static content

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotRegular = errors.New("file is not a regular file")

Functions

This section is empty.

Types

type Mirror

type Mirror struct {
	// The path to the root of the site. Default is `{http.vars.root}` if set,
	// or current working directory otherwise. This should be a trusted value.
	//
	// Note that a site root is not a sandbox. Although the file server does
	// sanitize the request URI to prevent directory traversal, files (including
	// links) within the site root may be directly accessed based on the request
	// path. Files and folders within the root should be secure and trustworthy.
	//
	// Responses from upstreams will be written to files within this root directory to be used as a local mirror of static content
	Root string `json:"root,omitempty"`

	// File name suffix to add to write ETags to.
	// If set, file ETags will be written to sidecar files
	// with this suffix.
	EtagFileSuffix string `json:"etag_file_suffix,omitempty"`

	UseXattr bool `json:"xattr,omitempty"`

	Sha256Xattr   bool `json:"sha256_xattr,omitempty"`
	HideTempFiles bool `json:"hide_temp_files,omitempty"`
	// contains filtered or unexported fields
}

func (Mirror) CaddyModule

func (Mirror) CaddyModule() caddy.ModuleInfo

func (*Mirror) Provision

func (mir *Mirror) Provision(ctx caddy.Context) error

Provision sets up the mirror handler

func (*Mirror) ServeHTTP

func (mir *Mirror) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

func (*Mirror) UnmarshalCaddyfile

func (mir *Mirror) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile parses the mirror directive. It enables the static mirror writer and configures it with this syntax:

mirror [<matcher>] [<root>] {
    root              <path>
    etag_file_suffix  <suffix>
    xattr             [<bool>]
    sha256            xattr
}

func (Mirror) Validate

func (mir Mirror) Validate() error

Validate validates that the module has a usable config.

Jump to

Keyboard shortcuts

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