Skip to main content

Server Configuration

The [server] section controls how PRISM listens for incoming requests, connects to your origin application, and manages connections.

TOML Example​

[server]
address = "127.0.0.1:4000"
origin = "http://localhost:3000"
mode = "bot-only"
shadow = false
drain_timeout_secs = 30
proxy_timeout_secs = 30
origin_keepalive_secs = 4
origin_connect_timeout_secs = 5
trusted_proxies = ["10.0.0.0/8", "172.16.0.0/12"]
max_connections = 10000
max_request_headers = 100

Parameters​

ParameterTypeDefaultDescription
addressString"127.0.0.1:4000"Socket address PRISM listens on
originString"http://localhost:3000"URL of your application server
modeString"bot-only"Render mode: bot-only or render-all
shadowBooleanfalseShadow mode: render in background, serve origin response
drain_timeout_secsInteger30Seconds to drain in-flight requests, including streamed bodies, during shutdown
proxy_timeout_secsInteger30Timeout in seconds for the origin response headers; for requests with a body it runs from the last body frame sent
origin_keepalive_secsInteger4How long an idle origin connection is kept for reuse. 0 = no reuse
origin_connect_timeout_secsInteger5Bound on establishing a TCP connection to the origin; a timeout is answered 502
origin_response_idle_secsIntegerproxy_timeout_secsLongest pause tolerated between origin response body frames
header_read_timeout_secsInteger15Deadline for incoming request headers
body_read_timeout_secsInteger30Idle timeout while reading request and streamed origin body frames
write_timeout_secsInteger60Closes a connection when no byte of a response can be written to the client for this long. 0 = no limit
max_request_bytesInteger10485760 (10 MiB)Request body limit; larger bodies get 413. 0 = no limit
max_response_bytesInteger52428800 (50 MiB)Origin response body limit; oversized declared bodies are rejected and oversized streams are aborted. 0 = no limit
public_base_urlString or nullnullPublic URL used for forwarded host validation and URL rewriting; defaults to origin
trusted_proxiesArray of Strings["127.0.0.0/8", "::1"]IP addresses/CIDRs whose forwarding headers are believed. Empty = trust none
max_connectionsInteger10000Maximum concurrent connections. 0 = unlimited
max_request_headersInteger100Most header fields one request may carry. Past it the connection is refused rather than buffered

Detailed Explanation​

address​

The IP and port PRISM binds to. Use 0.0.0.0:4000 to listen on all interfaces, or 127.0.0.1:4000 to restrict to localhost only.

origin​

The URL of your upstream application. All requests that do not require rendering (or all requests in proxy-only mode) are forwarded here. PRISM validates that this does not point to its own listen address to prevent infinite render loops. Listener addresses must be IP socket addresses. Origin and public-base URLs must use HTTP(S) and contain no credentials, query, or fragment; path prefixes are supported.

mode​

  • bot-only (default): Only render pages for detected bot user agents. Human visitors are proxied directly to the origin.
  • render-all: Render every matching request through the headless browser, regardless of user agent. Useful for fully static SEO output.

shadow​

When enabled, PRISM renders pages in the background but always serves the origin response to the client. It logs comparison statistics (origin bytes vs. rendered bytes) for validation purposes. This is useful for testing PRISM in production without affecting real traffic.

drain_timeout_secs​

During graceful shutdown (e.g., SIGTERM), PRISM stops accepting new connections, marks readiness as draining, and waits up to this many seconds for in-flight requests, including streamed response bodies. Remaining work is then cancelled and Chrome is shut down.

proxy_timeout_secs​

Maximum time to wait for a response from the origin server when proxying requests. If the origin does not respond within this window, PRISM returns a gateway timeout error.

For a request with a body, the clock starts again with every body frame sent to the origin. A large upload on a slow link is therefore not cut off while it is moving; it is cut off when no data has gone upstream for this long, and once the body is complete the origin has this long to send response headers. Requests without a body are bounded as before.

origin_keepalive_secs​

How long PRISM keeps an idle connection to the origin for reuse. The default of 4 seconds is below the 5 seconds at which Node.js and Apache close idle connections by default; a connection the origin has already closed fails the request sent on it. 0 disables reuse, so every request opens a new connection.

If the connection is closed or reset before any response arrives, a GET, HEAD or OPTIONS request without a body is sent once more within the same deadline. Nothing else is repeated. Retries are counted in prism_origin_retries_total.

origin_connect_timeout_secs​

How long PRISM waits to establish a TCP connection to the origin. A timeout is answered 502, like any other failure to reach the origin. Must be greater than 0.

origin_response_idle_secs​

How long the origin may pause between response body frames before PRISM aborts the response. Unset, it equals proxy_timeout_secs, which is what bounded this gap before the key existed. Raise it for server-sent events or long polling, or route those URLs around PRISM at your edge. Must be greater than 0 when set.

max_request_bytes and max_response_bytes​

Policy limits on the proxy path: a request body over max_request_bytes gets 413; an origin response over max_response_bytes is rejected with 502 when its declared length is over the limit, or aborted part-way otherwise. Bodies are streamed, not buffered, so these are not memory protection. 0 removes the limit. max_response_bytes = 0 used to be rejected at start-up, and the request limit was fixed at 10 MiB.

trusted_proxies​

PRISM believes X-Forwarded-For and X-Forwarded-Proto only from these addresses, so a client cannot spoof either.

The default is loopback, ["127.0.0.0/8", "::1"], which covers nginx, Apache or Caddy running on the same host as PRISM. An explicit list is used exactly as written: loopback is not added to it, so a list of CDN ranges no longer trusts a local proxy.

An explicit empty list, trusted_proxies = [], means nothing is trusted: both headers are ignored and the socket peer is treated as the client. That is the right setting when PRISM faces the internet directly. Behind a proxy it resolves every visitor to the proxy's address: the origin sees one client over http, all crawlers share one per-IP render budget (rate_limit_per_ip, three by default), and reverse-DNS bot verification judges the proxy instead of the crawler. When server.address is a loopback address and the list is empty, PRISM warns about this at startup.

X-Forwarded-For is read from every header line, as one comma-separated list, from right to left. Entries that are trusted proxies are skipped, and the first other entry is the client. Each entry must be an IP address (1.2.3.4, 1.2.3.4:5678, 2001:db8::1, [2001:db8::1] or [2001:db8::1]:5678). If PRISM reaches an entry that is not an address before it has found the client, it stops and uses the connection's peer address. Values a client forged on the left are therefore never reached while your own proxy appends the real address on the right.

A proxy that is not on loopback, such as a load balancer or a CDN edge, must be listed. When it is not, its X-Forwarded-For is ignored and PRISM treats it as the client. PRISM notices this when a peer that is not in the list, and whose address is not publicly routable (private, loopback, link-local, carrier-grade NAT or unique-local), sends X-Forwarded-For. You can spot it in two ways:

  • A WARN line, logged at most once every 10 minutes, naming the peer address and saying that X-Forwarded-For was ignored because that address is not in server.trusted_proxies.
  • The counter prism_untrusted_forwarded_requests_total, which increases for every such request. Any sustained increase means a proxy is missing from the list.

public_base_url​

The address visitors reach this instance at, when that differs from server.origin. Unset by default, in which case origin is used.

Set it whenever the origin is an internal name. Chrome renders the page at the origin, so anything the site builds from its own location (canonical links, og:url, hreflang, JSON-LD, redirect targets) otherwise carries that internal address into HTML served to crawlers. With it set, PRISM replaces the internal origin with this URL in links, images, srcset lists and JSON-LD. At startup PRISM warns when it is unset and origin is localhost, a loopback, private, link-local or unique-local IP address, a name without a dot, or a name ending in .local, .localhost, .internal, .lan, .svc or .cluster.local.

Since 1.4.0 it also pins X-Forwarded-Host. PRISM overwrites Host with the origin's own name, so the public one is passed along separately — and that value is whatever the client sent. A storefront deriving its base URL from it would build canonical links, redirects and sitemap entries pointing wherever the visitor asked. With public_base_url set, a Host that does not match it is replaced with the configured one.

Leave it unset only when you do not know the public hostname; PRISM then has nothing to check against and forwards the client's Host as before.

One instance, one public hostname​

A PRISM instance renders one site. Chrome always asks the origin for the origin's own host, and the hostname is not part of the cache key. If you point several public hostnames at one instance (an apex and www, or country domains), crawlers on every hostname receive the same render, the one made for the default host, under each hostname.

With public_base_url set, PRISM makes this visible without changing what it renders. A request that is about to be rendered, or served from the render cache, under a different hostname increases prism_other_host_render_requests_total and logs a WARN, at most once every 10 minutes, naming that hostname and the public host. The hostname comes from X-Forwarded-Host when the request arrives from a peer in server.trusted_proxies and carries the header, otherwise from Host. Case and port are ignored, and IP addresses and localhost are never counted. With public_base_url unset nothing is checked.

To serve more than one hostname, run one instance per hostname, or redirect the other hostnames to the public one at the edge.

[server]
origin = "http://app-service:3000"
public_base_url = "https://shop.example.com"

max_request_headers​

Header count only. The total header bytes are bounded separately and are not configurable: 8 KiB plus 4 KiB per header, past which the request is answered 431 Request Header Fields Too Large. That same ceiling bounds the request target, because the URI is parsed out of the same buffer — there is no separate URL-length setting because there does not need to be one.

The default matches what the HTTP layer would have used anyway. It is stated explicitly so that a dependency upgrade changing that default cannot move this deployment's posture silently; tests/inbound_limits.rs checks what a socket actually refuses rather than what a constant says.

max_connections​

Limits the number of simultaneous connections PRISM accepts. Once the limit is reached, a new connection is answered 503 Service Unavailable with Retry-After: 1 and Connection: close, then closed, so a client can tell overload from an outage. PRISM counts these in prism_connections_refused_total. If more than 256 of these answers are being written at once, further connections are closed without one. Set to 0 to disable the limit.

write_timeout_secs​

A client that stops reading mid-response would otherwise keep its connection, its max_connections slot and the origin connection behind it for ever. When PRISM cannot write a single byte of a response to the client for this many seconds, it closes the connection. Any progress, however slow, restarts the clock, so a slow client that keeps reading is not cut off. Idle keep-alive connections and slow uploads are not affected: they are governed by header_read_timeout_secs and body_read_timeout_secs. Set to 0 to remove the limit.

Example Use Cases​

Production behind a load balancer​

[server]
address = "0.0.0.0:4000"
origin = "http://app-service:3000"
mode = "bot-only"
trusted_proxies = ["10.0.0.0/8"]
max_connections = 5000

Testing with shadow mode​

[server]
address = "127.0.0.1:4000"
origin = "http://localhost:3000"
mode = "bot-only"
shadow = true

Full pre-rendering for all visitors​

[server]
address = "0.0.0.0:4000"
origin = "http://localhost:3000"
mode = "render-all"
proxy_timeout_secs = 15