Service struct defines a named service that can handle requests. Services are private within the config and referenced by name from sockets and bindings.
Structure
Name of the service. Used to refer to the service from elsewhere in the config file.Services are not accessible unless explicitly configured through a Socket or binding.
Service types
Each service must be one of the following types:Worker
A JavaScript/WebAssembly worker.See Worker schema for details.
Network
A service that implements access to a network.
fetch() requests are routed according to the URL hostname.Network addresses the worker can connect to, in CIDR notation or special strings:
public: Publicly-routable IP addressesprivate: Private network addresses (superset oflocal)local: Local machine addresses onlynetwork: Opposite oflocalunix: Unix domain socket addressesunix-abstract: Linux abstract Unix domain addresses
192.0.2.0/24, 2001:db8::/32Network addresses to deny, using the same format as
allow.TLS configuration for network connections.
External server
A service that forwards all requests to a specific remote server, typically a back-end on your internal network.
Address/port of the server. Examples:
1.2.3.4:80: IPv4 address and port[1234:5678::abcd]:80: IPv6 address and portunix:/path/to/socket: Unix domain socketunix-abstract:name: Linux abstract Unix socketexample.com:80: DNS hostname
Connect over unencrypted HTTP.
Connect over encrypted HTTPS.
options: HttpOptionstlsOptions: TlsOptionscertificateHost: Expected hostname in certificate
Disk directory
An HTTP service backed by a directory on disk, supporting basic HTTP GET/PUT.Not intended for direct internet exposure. Typically wrapped by a worker that adds proper Content-Type handling.
Filesystem path of the directory. Relative paths are interpreted relative to the server’s working directory.If not specified, must be provided via
--directory-path <service-name>=<path> command-line flag.Whether to support PUT requests for writing. Uses atomic file operations.
Whether to allow access to files/directories starting with
.. These are hidden by default since they often contain metadata.Example
Service designator
When referring to a service from elsewhere in the config (e.g., from a binding), use aServiceDesignator:
Name of the service in the
Config.services list.For modules-syntax workers with multiple named exports, specifies which entrypoint to use. Defaults to the default export.
Value to provide in
ctx.props in the target worker.empty: Empty object (default)json: JSON-encoded value
name is needed, you can use a raw string: