scgi

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

README

SCGI reverse proxy transport module for Caddy

This plugin adds SCGI reverse proxying support to Caddy.

The scgi transport module is based on the fastcgi transport module available.

SCGI Directive

To use the scgi directive, it must first be added under caddy's global setting:

{
  order   scgi after reverse_proxy
}
Syntax
scgi [<matcher>] <gateways...> {
  root <path>
  split <substrings...>
  env [<key> <value>]
  resolve_root_symlink
  dial_timeout  <duration>
  read_timeout  <duration>
  write_timeout <duration>

  <any other reverse_proxy subdirectives...>
}

Reverse Proxy

The scgi transport may also be specified under the reverse_proxy handler.

Expanded Form
route {
  reverse_proxy [<matcher>] <gateway> {
    transport scgi {
      ...
    }
  }
} 

Docker

You may download a pre-compiled version of caddy embedded with this module through the GitHub Container Registry using any of the below:

docker pull ghcr.io/elegant996/scgi-transport:1.0.3-caddy-2.7.5
docker pull ghcr.io/elegant996/scgi-transport:1.0.3
docker pull ghcr.io/elegant996/scgi-transport:latest

Documentation

Index

Constants

View Source
const FirstHeaderKey string = "CONTENT_LENGTH"

SCGI requires content length as the first header

Variables

View Source
var StatusRegex = regexp.MustCompile("(?i)(?:Status:|HTTP\\/[\\d\\.]+)\\s+(\\d{3}.*)")

StatusRegex describes the pattern for a raw HTTP Response code.

Functions

This section is empty.

Types

type Transport

type Transport struct {
	// Use this directory as the scgi root directory. Defaults to the root
	// directory of the parent virtual host.
	Root string `json:"root,omitempty"`

	// The path in the URL will be split into two, with the first piece ending
	// with the value of SplitPath. The first piece will be assumed as the
	// actual resource (CGI script) name, and the second piece will be set to
	// PATH_INFO for the CGI script to use.
	//
	// Future enhancements should be careful to avoid CVE-2019-11043,
	// which can be mitigated with use of a try_files-like behavior
	// that 404s if the scgi path info is not found.
	SplitPath []string `json:"split_path,omitempty"`

	// Path declared as root directory will be resolved to its absolute value
	// after the evaluation of any symbolic links.
	ResolveRootSymlink bool `json:"resolve_root_symlink,omitempty"`

	// Extra environment variables.
	EnvVars map[string]string `json:"env,omitempty"`

	// The duration used to set a deadline when connecting to an upstream. Default: `3s`.
	DialTimeout caddy.Duration `json:"dial_timeout,omitempty"`

	// The duration used to set a deadline when reading from the SCGI server.
	ReadTimeout caddy.Duration `json:"read_timeout,omitempty"`

	// The duration used to set a deadline when sending to the SCGI server.
	WriteTimeout caddy.Duration `json:"write_timeout,omitempty"`
	// contains filtered or unexported fields
}

Transport facilitates SCGI communication.

func (Transport) CaddyModule

func (Transport) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*Transport) Provision

func (t *Transport) Provision(ctx caddy.Context) error

Provision sets up t.

func (Transport) RoundTrip

func (t Transport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper.

func (*Transport) UnmarshalCaddyfile

func (t *Transport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile deserializes Caddyfile tokens into h.

transport scgi {
    root <path>
    split <at>
    env <key> <value>
    resolve_root_symlink
    dial_timeout <duration>
    read_timeout <duration>
    write_timeout <duration>
}

Jump to

Keyboard shortcuts

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