Networking
This section specifies how your Blocklet is exposed to the network. After defining how your Blocklet runs (see Execution), the next step is to configure its network interfaces, ports, and services through the interfaces
property in blocklet.yml
.
An interface defines a public endpoint for your Blocklet, mapping a URL path to an internal port where your application is listening. This allows Blocklet Server to route incoming requests correctly.
The interfaces
Property#
The interfaces
property is an array of objects, where each object defines a single network interface. A Blocklet can have multiple interfaces, for example, one for a public web UI and another for a .well-known
service.
Example: Basic Web Interface#
Here is a simple configuration for a web application:
# blocklet.yml
...
interfaces:
- type: web
name: publicUrl
path: /
prefix: '*'
protocol: http
port: BLOCKLET_PORT
...
This example defines a primary web interface named publicUrl
that can be mounted at any path (prefix: '*'
) and forwards traffic to the port defined by the BLOCKLET_PORT
environment variable.
Interface Properties#
Each object in the interfaces
array can have the following properties:
Property | Type | Description | Required |
---|---|---|---|
|
| The type of interface. Valid values are | Yes |
|
| A unique, human-readable name for the interface (e.g., | Yes |
|
| The root path inside the Blocklet that this interface serves. Defaults to | No |
|
| The URL prefix where the interface is mounted. | No |
|
| The protocol used. Valid values are | No |
|
| Defines the port mapping. Can be a string (e.g., | No |
|
| The port number inside the container to expose. Primarily used for Docker-based Blocklets. | No |
|
| Binds the interface to a specific host IP address ( | No |
|
| Determines how requests are handled. | No |
|
| An array of path prefixes (e.g., | No |
|
| An array of services to attach to this interface, such as authentication. See the Features section for details. | No |
|
| An array of OCAP (Open Component Access Protocol) endpoints exposed by this interface, defining a structured API. | No |
Advanced Example: Multiple Interfaces#
This example shows a Blocklet with two distinct interfaces: one for the main application and another for a specific /.well-known
configuration.
# blocklet.yml
...
interfaces:
- type: web
name: web
path: /
prefix: '*'
port: BLOCKLET_PORT
services:
- name: auth-service
config:
whoCanAccess: 'all'
- type: wellknown
name: assetlinks
path: /assetlinks.json
prefix: /.well-known/assetlinks.json
port: BLOCKLET_PORT
proxyBehavior: direct
...
In this configuration:
- The
web
interface is protected by an authentication service. - The
wellknown
interface provides a publicassetlinks.json
file, bypassing any services for direct access.
Now that you understand how to configure your Blocklet's network presence, you can proceed to the next section to learn how to declare system requirements and dependencies.
Next: Dependencies