proxy

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(cfg Config) fasthttp.RequestHandler

Handler creates a fasthttp.RequestHandler that proxies to the FastCGI upstream.

Types

type Config

type Config struct {
	// Network is the FastCGI upstream network type ("tcp" or "unix").
	Network string
	// Address is the FastCGI upstream address (e.g., "127.0.0.1:9000" or "/run/php/php-fpm.sock").
	Address string
	// DocumentRoot is the root directory for PHP scripts on the upstream server.
	DocumentRoot string
	// Index is the default index file (default: "index.php").
	Index string
	// ListenPort is the port the proxy listens on (for SERVER_PORT).
	ListenPort string
	// DialTimeout for upstream connections.
	DialTimeout time.Duration
	// ReadTimeout for upstream reads.
	ReadTimeout time.Duration
	// WriteTimeout for upstream writes.
	WriteTimeout time.Duration
	// ResponseHeaders are additional headers added to every response.
	ResponseHeaders map[string]string
	// Locations defines external proxy locations with caching.
	Locations []locationcache.Location
	// LocationCache is an optional pre-built cache (for testing). If set, Locations is ignored.
	LocationCache *locationcache.Cache
	// StaticLocations defines paths that serve a pre-built inline response
	// without any upstream call. Matched by exact path before the cache.
	StaticLocations map[string]StaticResponse
	// Pool configures the FastCGI connection pool.
	Pool fcgi.PoolConfig
	// CORS configures Cross-Origin Resource Sharing. When Enabled is false,
	// CORS handling is a no-op.
	CORS config.ParsedCORS
	// Auth configures HTTP authentication applied before the FCGI dispatch.
	// Bypasses /healthz, /readyz, static locations, and cached upstream
	// locations (they serve before the auth check runs).
	Auth config.ParsedAuth
	// Readiness configures the /readyz endpoint that probes PHP-FPM's
	// status page. When Enabled is false, /readyz behaves like /healthz.
	Readiness config.ParsedReadiness
}

Config holds proxy configuration.

type StaticResponse added in v1.1.0

type StaticResponse struct {
	Status      int
	Body        []byte
	ContentType string
}

StaticResponse is a materialized inline response served for a configured location path. Fields correspond to config.ParsedReturn.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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