http

package module
v6.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 31 Imported by: 0

README

PROXY Protocol

Plain HTTP and HTTPS TCP listeners have separate PROXY protocol settings. Both support v1 and v2:

http:
  address: 0.0.0.0:8080
  proxy_protocol:
    trusted_proxies: ["10.20.0.0/24"]
    read_header_timeout: 5s
  ssl:
    address: 0.0.0.0:8443
    cert: server.pem
    key: server-key.pem
    proxy_protocol:
      trusted_proxies: ["10.30.0.10"]
      read_header_timeout: 5s

Omit proxy_protocol to leave that listener unchanged. An enabled listener accepts connections only from trusted_proxies. This list must contain the IP addresses or CIDR ranges of the immediate proxies. Each connection must start with a PROXY header, including health check connections. The listener drops all other connections.

If you omit read_header_timeout or set it to zero, the timeout is 5s. Negative values are invalid.

For HTTPS, send the PROXY header before the TLS handshake. HTTP/1.1, h2c, TLS HTTP/2, and WebSocket upgrades through Go middleware continue to work.

TCP4 and TCP6 headers set the client address in handlers, access logs, and PHP's REMOTE_ADDR. Valid v1 UNKNOWN and v2 LOCAL headers retain the socket addresses. The parser ignores TLVs. They do not change TLS state or the URL scheme.

PROXY metadata applies to the whole connection. A proxy must use separate backend connections for different client identities.

These settings do not affect FastCGI, HTTP/3, or CertMagic's temporary ACME challenge listeners. Send challenge traffic to those listeners without PROXY headers.

proxy_ip_parser and http.trusted_subnets control HTTP forwarding headers separately. With PROXY enabled, RemoteAddr contains the advertised client address instead of the immediate proxy address. Check forwarding header trust settings for this address change.

The parser (go-proxyproto v0.15.0) can reject fragmented v1 headers. It limits the v2 address and TLV payload to 4096 bytes. Use v2 if the proxy supports it.

Documentation

Overview

Package http implements the RoadRunner HTTP plugin, orchestrating HTTP/HTTPS/HTTP3/FastCGI servers and PHP worker pools to serve PSR-7-compatible requests.

Index

Constants

View Source
const (
	// PluginName declares plugin name.
	PluginName        = "http"
	MB         uint64 = 1024 * 1024

	// RrMode RR_HTTP env variable key (internal) if the HTTP presents
	RrMode     = "RR_MODE"
	RrModeHTTP = "http"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Informer

type Informer interface {
	Workers() []*process.State
}

type Plugin

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

Plugin manages pool, http servers. The main http plugin structure

func (*Plugin) AddWorker

func (p *Plugin) AddWorker() error

func (*Plugin) Collects

func (p *Plugin) Collects() []*dep.In

Collects collecting http middlewares

func (*Plugin) Init

func (p *Plugin) Init(cfg api.Configurer, log api.Logger, srv api.Server) error

Init must return configure svc and return true if svc hasStatus enabled. Must return error in case of misconfiguration. Services must not be used without proper configuration pushed first.

func (*Plugin) MetricsCollector

func (p *Plugin) MetricsCollector() []prometheus.Collector

func (*Plugin) Name

func (p *Plugin) Name() string

Name returns endure.Named interface implementation

func (*Plugin) Ready

func (p *Plugin) Ready() (*status.Status, error)

Ready return readiness status of the particular plugin

func (*Plugin) RemoveWorker

func (p *Plugin) RemoveWorker(ctx context.Context) error

func (*Plugin) Reset

func (p *Plugin) Reset() error

Reset destroys the old pool and replaces it with new one, waiting for old pool to die

func (*Plugin) Serve

func (p *Plugin) Serve() chan error

Serve serves the svc.

func (*Plugin) ServeHTTP

func (p *Plugin) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles connection using set of middleware and pool PSR-7 server.

func (*Plugin) Status

func (p *Plugin) Status() (*status.Status, error)

Status return status of the particular plugin

func (*Plugin) Stop

func (p *Plugin) Stop(ctx context.Context) error

Stop stops the http.

func (*Plugin) Workers

func (p *Plugin) Workers() []*process.State

Workers returns slice with the process states for the workers

type StatsExporter

type StatsExporter struct {
	TotalMemoryDesc  *prometheus.Desc
	StateDesc        *prometheus.Desc
	WorkerMemoryDesc *prometheus.Desc
	TotalWorkersDesc *prometheus.Desc

	WorkersReady   *prometheus.Desc
	WorkersWorking *prometheus.Desc
	WorkersInvalid *prometheus.Desc

	Workers Informer
}

func (*StatsExporter) Collect

func (s *StatsExporter) Collect(ch chan<- prometheus.Metric)

func (*StatsExporter) Describe

func (s *StatsExporter) Describe(d chan<- *prometheus.Desc)

type StdLogAdapter

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

StdLogAdapter can be passed to the http.Server or any place which required standard logger to redirect output to the logger plugin

func NewStdAdapter

func NewStdAdapter(log *slog.Logger) *StdLogAdapter

NewStdAdapter constructs StdLogAdapter

func (*StdLogAdapter) Write

func (s *StdLogAdapter) Write(p []byte) (n int, err error)

Write io.Writer interface implementation

Directories

Path Synopsis
Package acme provides automatic TLS certificate issuance and management via Let's Encrypt using the ACME protocol.
Package acme provides automatic TLS certificate issuance and management via Let's Encrypt using the ACME protocol.
Package api defines the core interfaces shared across the HTTP plugin, including worker pool, server, middleware, configuration, and logger contracts.
Package api defines the core interfaces shared across the HTTP plugin, including worker pool, server, middleware, configuration, and logger contracts.
Package attributes manages PSR-7-style request attributes stored in the request context, enabling data passing from Go middleware to PHP workers.
Package attributes manages PSR-7-style request attributes stored in the request context, enabling data passing from Go middleware to PHP workers.
Package config defines the configuration structures for the HTTP plugin, covering server addresses, TLS, FastCGI, HTTP2/3, upload handling, and worker pool settings.
Package config defines the configuration structures for the HTTP plugin, covering server addresses, TLS, FastCGI, HTTP2/3, upload handling, and worker pool settings.
Package handler transforms incoming HTTP requests into PSR-7-compatible protobuf payloads, dispatches them to PHP workers, and writes back responses.
Package handler transforms incoming HTTP requests into PSR-7-compatible protobuf payloads, dispatches them to PHP workers, and writes back responses.
Package middleware provides built-in HTTP middleware for request size limiting, HTTP-to-HTTPS redirection, and access logging.
Package middleware provides built-in HTTP middleware for request size limiting, HTTP-to-HTTPS redirection, and access logging.
Package servers defines the internal interface for starting and stopping the various HTTP server implementations.
Package servers defines the internal interface for starting and stopping the various HTTP server implementations.
fcgi
Package fcgi implements a FastCGI server that serves HTTP requests over the FastCGI protocol.
Package fcgi implements a FastCGI server that serves HTTP requests over the FastCGI protocol.
http11
Package http implements a plain HTTP/1.1 server with optional h2c (HTTP/2 cleartext) support.
Package http implements a plain HTTP/1.1 server with optional h2c (HTTP/2 cleartext) support.
http3
Package http3 implements an HTTP/3 server using QUIC with TLS and optional ACME certificate support.
Package http3 implements an HTTP/3 server using QUIC with TLS and optional ACME certificate support.
https
Package https implements an HTTPS server with TLS, optional mutual TLS client authentication, HTTP/2, and ACME certificate automation.
Package https implements an HTTPS server with TLS, optional mutual TLS client authentication, HTTP/2, and ACME certificate automation.
Package tlsconf provides a secure default TLS configuration with hardware-aware cipher suite selection.
Package tlsconf provides a secure default TLS configuration with hardware-aware cipher suite selection.

Jump to

Keyboard shortcuts

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