Basic socket configuration
Sockets are defined in thesockets list of your configuration:
Socket fields
Unique name for the socket. Used with command-line overrides:
--socket-addr <name>=<addr>: Override the address--socket-fd <name>=<fd>: Use an inherited file descriptor
Address and port to listen on. Optional if you plan to specify it on the command line.Examples:
"*:80": All interfaces, port 80"1.2.3.4": Specific IPv4 address, default port"1.2.3.4:8080": Specific IPv4 address and port"1234:5678::abcd": IPv6 address, default port"[1234:5678::abcd]:8080": IPv6 address and port"unix:/path/to/socket": Unix domain socket"unix-abstract:name": Linux abstract Unix socket"example.com:8080": DNS hostname (resolves and listens on all addresses)
Service name that handles requests on this socket.
Protocol configuration
Sockets support HTTP and HTTPS protocols:HTTP
For unencrypted HTTP connections:HTTPS
For TLS-encrypted connections:HTTP options
HTTP options configure request/response behavior, particularly for proxy scenarios:HTTP style:
host: Normal HTTP (path in request line, separate Host header)proxy: HTTP proxy protocol (full URL in request line)
Header name containing the original protocol (
"http" or "https"). Useful when behind a reverse proxy that performs TLS termination.Common values: "X-Forwarded-Proto", "X-Real-Proto"Header name for encoding/parsing the
request.cf object as JSON. If not set, request.cf is discarded on send and undefined on receipt.Headers automatically injected into all incoming requests. Existing headers with the same name are removed.
Headers automatically injected into all outgoing responses.
Host+port for Cap’n Proto RPC connections. CONNECT requests for this host are treated as requests to form a Cap’n Proto RPC connection, exposing a WorkerdBootstrap interface.
TLS options
TLS configuration for encrypted connections:Private key and certificate chain. Optional for clients, required for servers.
privateKey: PEM format, supports PKCS8, traditional RSA, and DSA keyscertificateChain: PEM format, concatenate multiple certificates starting with the leaf
Require clients to present certificates signed by trusted CAs. Typically used with
trustBrowserCas = false and a specific private CA in trustedCertificates.Trust certificates signed by browser-trusted CAs. Set
true for public internet, false for internal networks.Additional CA certificates to trust, in PEM format.
Minimum TLS version allowed:
goodDefault: Chosen by maintainers, may changessl3,tls1Dot0,tls1Dot1: Legacy versionstls1Dot2,tls1Dot3: Modern versions
Only override this if you have specific backwards-compatibility needs.
OpenSSL cipher list string. The default is based on Mozilla’s “intermediate” recommendations and changes with cryptanalysis developments.Only specify your own if:
- You need extreme backwards-compatibility
- You need to quickly disable a recently-broken algorithm
Multiple sockets
You can define multiple sockets listening on different addresses or ports:Command-line overrides
You can override socket addresses from the command line:Systemd integration
workerd works well with systemd socket activation:Complete example
Next steps
Services
Configure services to handle requests
Workers
Set up worker services