listen
The listen clause configures the network interfaces and ports on which the HTTP server accepts requests. HTTP servers support TCP and TLS protocols (UDP is not supported).
Basic Configuration
listen {
protocol tcp;
port 8000;
ip 0.0.0.0;
}
Parameters
| Parameter | Description | Required |
|---|---|---|
| protocol | Transport protocol: tcp or tls | Yes |
| port | Port number to listen on | Yes |
| ip | IP address(es) to bind (can specify multiple) | Yes |
| buffer | Socket buffer size in bytes | No |
| timeout | Connection idle timeout | No |
| keepalive | TCP keepalive configuration | No |
| tls | TLS configuration block (required when protocol is tls) | Conditional |
TLS Configuration
When using protocol tls, a tls block is required:
listen {
protocol tls;
port 8443;
ip 0.0.0.0;
tls {
# Server certificate (required)
certificate "SERVER_CERT";
# Server private key (required)
certificate_key "SERVER_KEY";
# Server CA certificate chain (required)
server_ca_certificate "CA_CERT";
# Whether to require client certificates (optional, default: false)
require_client_certificate false;
# CA for validating client certificates (required if require_client_certificate is true)
client_ca_certificate "CLIENT_CA";
}
}
The TLS configuration enables HTTPS with HTTP/1.1 and HTTP/2 support. Certificate names reference certificates defined in the certificates block.
Multiple IP Addresses
You can bind to multiple IP addresses by specifying multiple ip statements:
listen {
protocol tcp;
port 8000;
ip 0.0.0.0; # All IPv4 addresses
ip ::; # All IPv6 addresses
ip 10.0.0.1; # Specific address
}
Example: HTTP with Timeout and Keepalive
listen {
protocol tcp;
port 8000;
ip 0.0.0.0;
# Close idle connections after 30 seconds
timeout 30s;
# TCP keepalive to detect dead connections
keepalive {
idle 60s;
interval 10s;
count 3;
}
}
See Also
- servers.http - HTTP server configuration
- servers.timeout - Connection timeout configuration
- servers.keepalive - TCP keepalive configuration