Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Architecture

                          +------------------------------+
 client --TCP--> :443 --> | pre-filter (Tokio)           | --loopback--> Pingora 127.0.0.1:4443
                          | conn-rate gate, abuse box,   |               TLS (BoringSSL), SNI certs,
                          | ClientHello checks, budgets  |               WAF, limits, routing
                          +------------------------------+                    |
                                                                              v
 client --HTTP--> :80 --> ACME HTTP-01 challenges, else 301 to https    upstreams / static roots

 127.0.0.1:9090   /metrics, /health, /api/*
 unix socket      config status, verify, reload; certificate status and warmup
  1. The pre-filter reads the ClientHello and decides if the connection is worth it.
  2. Good ones get spliced to Pingora on 127.0.0.1:4443. The real client IP goes along through a table keyed by the loopback source port, so no PROXY protocol.
  3. Pingora terminates TLS and picks the cert by SNI.
  4. Request checks, limits, routing, then upstream or a file from disk.
  5. :80 answers ACME challenges and redirects the rest to HTTPS.

Why the pre-filter: Pingora sets up TLS state as soon as it accepts. A flood of half-open, non-TLS or slow connections can use that up before any HTTP check runs. Reading a ClientHello first is a lot cheaper. The cost is one loopback hop and one local port per connection.

Around it: one reload task owns the config, a unix socket for control calls, the metrics listener, and a background job that renews on-demand certs.

Source

File
main.rsboot, runtimes, Pingora server
tls_router.rsthe :443 pre-filter
proxy.rsPingora ProxyHttp: filters, routing, upstreams
h2_guard.rsrapid reset guard
limiter.rs, breaker.rsrate limits, penalty box, breaker
acme.rs, on_demand.rsACME bundle, on-demand certs
static_handler.rsstatic files
config.rsconfig and defaults
check.rs, check_rules.rs--check
reload.rshot reload
shield.rs, blocklist.rsCloudflare and crawler ranges, blocklist
metrics.rs, control.rs, cli.rsmetrics, control socket, CLI
tuning.rsmemory sizing

Tests

cargo test

Unit tests for the parts (parsers, limiters, breaker, budgets, config checks, static files). No end-to-end suite, so also try changes with the local setup.