scgi

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: Apache-2.0 Imports: 27 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 php_fastcgi
}
Syntax
scgi [<matcher>] <gateways...> {
	env [<key> <value>]
	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 {
      ...
    }
  }
} 

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SCGIClient

type SCGIClient struct {
	// contains filtered or unexported fields
}

SCGIClient implements a SCGI client, which is a standard for interfacing external applications with Web servers.

func Dial

func Dial(network, address string) (scgi *SCGIClient, err error)

Dial connects to the scgi responder at the specified network address, using default net.Dialer. See func net.Dial for a description of the network and address parameters.

func DialContext

func DialContext(ctx context.Context, network, address string) (scgi *SCGIClient, err error)

DialContext is like Dial but passes ctx to dialer.Dial.

func DialWithDialerContext

func DialWithDialerContext(ctx context.Context, network, address string, dialer net.Dialer) (scgi *SCGIClient, err error)

DialWithDialerContext connects to the scgi responder at the specified network address, using custom net.Dialer and a context. See func net.Dial for a description of the network and address parameters.

func (*SCGIClient) Close

func (c *SCGIClient) Close()

Close closes scgi connection

func (*SCGIClient) Do

func (c *SCGIClient) Do(p map[string]string, req io.Reader) (r io.Reader, err error)

Do made the request and returns a io.Reader that translates the data read from scgi responder out of scgi packet before returning it.

func (*SCGIClient) Get

func (c *SCGIClient) Get(p map[string]string, body io.Reader, l int64) (resp *http.Response, err error)

Get issues a GET request to the scgi responder.

func (*SCGIClient) Head

func (c *SCGIClient) Head(p map[string]string) (resp *http.Response, err error)

Head issues a HEAD request to the scgi responder.

func (*SCGIClient) Options added in v0.2.0

func (c *SCGIClient) Options(p map[string]string) (resp *http.Response, err error)

Options issues an OPTIONS request to the scgi responder.

func (*SCGIClient) Post

func (c *SCGIClient) Post(p map[string]string, method string, bodyType string, body io.Reader, l int64) (resp *http.Response, err error)

Post issues a POST request to the scgi responder. with request body in the format that bodyType specified

func (*SCGIClient) PostFile added in v0.2.0

func (c *SCGIClient) PostFile(p map[string]string, data url.Values, file map[string]string) (resp *http.Response, err error)

PostFile issues a POST to the scgi responder in multipart(RFC 2046) standard, with form as a string key to a list values (url.Values), and/or with file as a string key to a list file path.

func (*SCGIClient) PostForm added in v0.2.0

func (c *SCGIClient) PostForm(p map[string]string, data url.Values) (resp *http.Response, err error)

PostForm issues a POST to the scgi responder, with form as a string key to a list values (url.Values)

func (*SCGIClient) Request

func (c *SCGIClient) Request(p map[string]string, req io.Reader) (resp *http.Response, err error)

Request returns a HTTP Response with Header and Body from scgi responder

func (*SCGIClient) SetReadTimeout

func (c *SCGIClient) SetReadTimeout(t time.Duration) error

SetReadTimeout sets the read timeout for future calls that read from the scgi responder. A zero value for t means no timeout will be set.

func (*SCGIClient) SetWriteTimeout

func (c *SCGIClient) SetWriteTimeout(t time.Duration) error

SetWriteTimeout sets the write timeout for future calls that send data to the scgi responder. A zero value for t means no timeout will be set.

type Transport

type Transport struct {
	// 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 {
    env <key> <value>
}

Jump to

Keyboard shortcuts

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