Documentation
¶
Overview ¶
Package reversebin provides a Caddy HTTP handler (`reverse-bin`) that starts an executable backend and proxies requests to it.
The module is intended for backends that should be started on demand and terminated after inactivity.
Index ¶
- Variables
- type DetectorOutput
- type ReverseBin
- func (c *ReverseBin) CaddyModule() caddy.ModuleInfo
- func (c *ReverseBin) Cleanup() error
- func (c *ReverseBin) GetUpstreams(r *http.Request) ([]*reverseproxy.Upstream, error)
- func (c *ReverseBin) Provision(ctx caddy.Context) error
- func (c *ReverseBin) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
- func (c *ReverseBin) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
Constants ¶
This section is empty.
Variables ¶
var ( Version = "dev" Commit = "none" BuildDate = "unknown" )
Build-time metadata set via -ldflags during release builds.
Functions ¶
This section is empty.
Types ¶
type DetectorOutput ¶ added in v0.2.2
type DetectorOutput = detectorschema.DetectorOutput
DetectorOutput is the JSON object a dynamic proxy detector writes to stdout.
type ReverseBin ¶
type ReverseBin struct {
// Name of executable script or binary and its arguments
Executable []string `json:"executable"`
// Working directory (default, current Caddy working directory)
WorkingDirectory string `json:"workingDirectory,omitempty"`
// Environment key value pairs (key=value) for this particular app
Envs []string `json:"envs,omitempty"`
// Environment keys to pass through for all apps
PassEnvs []string `json:"passEnvs,omitempty"`
// True to pass all environment variables to the executable
PassAll bool `json:"passAllEnvs,omitempty"`
// Address to proxy to (for proxy mode)
ReverseProxyTo string `json:"reverse_proxy_to,omitempty"`
// Health check method (GET or HEAD)
HealthMethod string `json:"healthMethod,omitempty"`
// Health check path
HealthPath string `json:"healthPath,omitempty"`
// Exact health check status; zero accepts any 2xx/3xx response
HealthStatus int `json:"healthStatus,omitempty"`
// Binary and arguments to run to determine proxy parameters dynamically
DynamicProxyDetector []string `json:"dynamic_proxy_detector,omitempty"`
// Idle timeout in milliseconds before stopping backend process after last request
IdleTimeoutMS int `json:"idleTimeoutMs,omitempty"`
// Health timeout in milliseconds before startup fails
HealthTimeoutMS int `json:"healthTimeoutMs,omitempty"`
// Termination grace in milliseconds before SIGKILL
TerminationGraceMS int `json:"terminationGraceMs,omitempty"`
// Kill wait in milliseconds after SIGKILL before reporting failure
TerminationKillWaitMS int `json:"terminationKillWaitMs,omitempty"`
// contains filtered or unexported fields
}
ReverseBin supervises executable backends and proxies HTTP traffic to them.
func (*ReverseBin) CaddyModule ¶
func (c *ReverseBin) CaddyModule() caddy.ModuleInfo
func (*ReverseBin) Cleanup ¶
func (c *ReverseBin) Cleanup() error
func (*ReverseBin) GetUpstreams ¶
func (c *ReverseBin) GetUpstreams(r *http.Request) ([]*reverseproxy.Upstream, error)
GetUpstreams implements reverseproxy.UpstreamSource which allows dynamic selection of backend process ensures process is running before returning the upstream address to the proxy. Note: In Caddy's reverse_proxy, GetUpstreams is called before ServeHTTP. For the very first request that triggers a process start, the request tracking must be initialized here to ensure the idle timer starts correctly after the first request completes.
func (*ReverseBin) Provision ¶
func (c *ReverseBin) Provision(ctx caddy.Context) error
Provision implements caddy.Provisioner; it sets up the module's internal state and provisions the underlying reverse proxy handler.
func (*ReverseBin) ServeHTTP ¶
func (c *ReverseBin) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
ServeHTTP implements caddyhttp.MiddlewareHandler; it handles the HTTP request manages idle process killing
func (*ReverseBin) UnmarshalCaddyfile ¶
func (c *ReverseBin) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile implements caddyfile.Unmarshaler; it parses the reverse-bin directive and its subdirectives from the Caddyfile.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
caddy
command
Package main is the entry point of the Caddy application.
|
Package main is the entry point of the Caddy application. |
|
gen-detector-schema
command
|
|
|
detectorschema
module
|