|
1 | 1 | --- |
2 | 2 | # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
3 | 3 | # SPDX-License-Identifier: Apache-2.0 |
4 | | -title: "Configure and Operate Supervisor Middleware" |
5 | | -sidebar-title: "Configure and Operate" |
| 4 | +title: "Supervisor Middleware Configuration" |
| 5 | +sidebar-title: "Configuration" |
6 | 6 | slug: "extensibility/supervisor-middleware/configure" |
7 | 7 | description: "Attach supervisor middleware to sandbox traffic, register your own middleware services, and observe middleware decisions." |
8 | 8 | keywords: "Supervisor Middleware, Configuration, Network Policy, Operations, OCSF, Logging" |
9 | 9 | --- |
10 | 10 |
|
11 | | -You attach middleware to destination hosts in sandbox policy. Built-in middleware needs only a policy entry. Your own middleware service also needs a registration in gateway configuration. |
| 11 | +Register your middleware service in gateway configuration, then attach it to destination hosts in sandbox policy. This page also covers ordering, failure behavior, service lifecycle, and observability. Built-in middleware needs only a policy entry. |
| 12 | + |
| 13 | +## Use Your Own Middleware Service |
| 14 | + |
| 15 | +A middleware service is a gRPC server that implements the supervisor middleware protocol. The [content guard example](https://github.com/NVIDIA/OpenShell/tree/main/examples/supervisor-middleware-content-guard) implements request, response, and WebSocket checks in one service, and includes a policy and a local launcher. |
| 16 | + |
| 17 | +To use your own service: |
| 18 | + |
| 19 | +1. Start the service where both the gateway and sandbox supervisors can reach it. |
| 20 | +2. Register it in gateway configuration. |
| 21 | +3. Restart the gateway. |
| 22 | +4. Attach it in sandbox policy by setting `middleware` to the registration `name`. |
| 23 | + |
| 24 | +Register the service in gateway TOML: |
| 25 | + |
| 26 | +```toml |
| 27 | +[[openshell.supervisor.middleware]] |
| 28 | +name = "content-guard" |
| 29 | +grpc_endpoint = "https://content-guard.example:50051" |
| 30 | +tls_ca_cert_path = "/path/to/content-guard-ca.pem" |
| 31 | +max_payload_bytes = 262144 |
| 32 | +timeout = "500ms" |
| 33 | +``` |
| 34 | + |
| 35 | +<ParamField path="name" type="string" required={true}> |
| 36 | + Unique name that policies use to attach the service. The `openshell/` prefix is reserved for built-ins. |
| 37 | +</ParamField> |
| 38 | + |
| 39 | +<ParamField path="grpc_endpoint" type="string" required={true}> |
| 40 | + Service address reachable from the gateway and sandbox supervisors. |
| 41 | +</ParamField> |
| 42 | + |
| 43 | +<ParamField path="max_payload_bytes" type="integer" required={true}> |
| 44 | + Largest request body, response body, or WebSocket message the service inspects. Must be at most 4 MiB and no larger than the service advertises. |
| 45 | +</ParamField> |
| 46 | + |
| 47 | +<ParamField path="timeout" type="string" default="500ms"> |
| 48 | + Time limit for `Describe`, `ValidateConfig`, and individual evaluations or stream exchanges. Use an integer followed by `ms` or `s`, from `10ms` through `30s`. A binding may advertise a shorter evaluation timeout. Accepted HTTP response and WebSocket streams have no connection-wide deadline. |
| 49 | +</ParamField> |
| 50 | + |
| 51 | +<ParamField path="tls_ca_cert_path" type="string"> |
| 52 | + Private CA for the service certificate. Without it, OpenShell uses platform trust roots. |
| 53 | +</ParamField> |
| 54 | + |
| 55 | +<ParamField path="audience" type="string" default="urn:openshell:extension:middleware:<name>"> |
| 56 | + Token audience. Refer to [Extension Authentication](/extensibility/extension-authentication). |
| 57 | +</ParamField> |
| 58 | + |
| 59 | +<ParamField path="allow_insecure_transport" type="boolean" default="false"> |
| 60 | + Allows a plaintext `http://` endpoint with no authentication. Use it for local development or on a network that already authenticates callers. |
| 61 | +</ParamField> |
| 62 | + |
| 63 | +At startup, the gateway contacts every registered service to read its capabilities and verify [protocol compatibility](/extensibility/extension-negotiation). The gateway does not start if a service is unavailable or incompatible. [Gateway Configuration](/reference/gateway-config#supervisor-middleware-services) describes the full TOML context. |
| 64 | + |
| 65 | +When the gateway has JWT signing configured, OpenShell authenticates every call to your service with a short-lived token. [Extension Authentication](/extensibility/extension-authentication) describes how your service validates it. |
12 | 66 |
|
13 | 67 | ## Attach Middleware in Policy |
14 | 68 |
|
@@ -43,6 +97,7 @@ network_middlewares: |
43 | 97 | order: 10 |
44 | 98 | endpoints: |
45 | 99 | include: ["*.example.com"] |
| 100 | + exclude: ["trusted.example.com"] |
46 | 101 | content-guard: |
47 | 102 | name: Content guard |
48 | 103 | middleware: content-guard |
@@ -108,60 +163,6 @@ The map key, such as `content-guard`, is the entry's stable identity in logs. Ea |
108 | 163 |
|
109 | 164 | [Policy Schema](/reference/policy-schema#network-middleware) lists every field and limit. |
110 | 165 |
|
111 | | -## Use Your Own Middleware Service |
112 | | - |
113 | | -A middleware service is a gRPC server that implements the supervisor middleware protocol. The [content guard example](https://github.com/NVIDIA/OpenShell/tree/main/examples/supervisor-middleware-content-guard) implements request, response, and WebSocket checks in one service, and includes a policy and a local launcher. |
114 | | - |
115 | | -To use your own service: |
116 | | - |
117 | | -1. Start the service where both the gateway and sandbox supervisors can reach it. |
118 | | -2. Register it in gateway configuration. |
119 | | -3. Restart the gateway. |
120 | | -4. Attach it in sandbox policy by setting `middleware` to the registration `name`. |
121 | | - |
122 | | -Register the service in gateway TOML: |
123 | | - |
124 | | -```toml |
125 | | -[[openshell.supervisor.middleware]] |
126 | | -name = "content-guard" |
127 | | -grpc_endpoint = "https://content-guard.example:50051" |
128 | | -tls_ca_cert_path = "/path/to/content-guard-ca.pem" |
129 | | -max_payload_bytes = 262144 |
130 | | -timeout = "500ms" |
131 | | -``` |
132 | | - |
133 | | -<ParamField path="name" type="string" required={true}> |
134 | | - Unique name that policies use to attach the service. The `openshell/` prefix is reserved for built-ins. |
135 | | -</ParamField> |
136 | | - |
137 | | -<ParamField path="grpc_endpoint" type="string" required={true}> |
138 | | - Service address reachable from the gateway and sandbox supervisors. |
139 | | -</ParamField> |
140 | | - |
141 | | -<ParamField path="max_payload_bytes" type="integer" required={true}> |
142 | | - Largest request body, response body, or WebSocket message the service inspects. Must be at most 4 MiB and no larger than the service advertises. |
143 | | -</ParamField> |
144 | | - |
145 | | -<ParamField path="timeout" type="string" default="500ms"> |
146 | | - Time limit for each call to the service. Must be 10 ms-30 s. |
147 | | -</ParamField> |
148 | | - |
149 | | -<ParamField path="tls_ca_cert_path" type="string"> |
150 | | - Private CA for the service certificate. Without it, OpenShell uses platform trust roots. |
151 | | -</ParamField> |
152 | | - |
153 | | -<ParamField path="audience" type="string" default="urn:openshell:extension:middleware:<name>"> |
154 | | - Token audience. Refer to [Extension Authentication](/extensibility/extension-authentication). |
155 | | -</ParamField> |
156 | | - |
157 | | -<ParamField path="allow_insecure_transport" type="boolean" default="false"> |
158 | | - Allows a plaintext `http://` endpoint with no authentication. Use it for local development or on a network that already authenticates callers. |
159 | | -</ParamField> |
160 | | - |
161 | | -At startup, the gateway contacts every registered service to read its capabilities and verify [protocol compatibility](/extensibility/extension-negotiation). The gateway does not start if a service is unavailable or incompatible. [Gateway Configuration](/reference/gateway-config#supervisor-middleware-services) describes the full TOML context. |
162 | | - |
163 | | -When the gateway has JWT signing configured, OpenShell authenticates every call to your service with a short-lived token. [Extension Authentication](/extensibility/extension-authentication) describes how your service validates it. |
164 | | - |
165 | 166 | ## Choose Failure Behavior |
166 | 167 |
|
167 | 168 | Middleware fails when it cannot complete its check, for example when its service is unavailable, times out, returns an invalid result, or receives a payload over its limit. By default, OpenShell blocks the affected request, response, or WebSocket connection. The `on_error` field on a policy entry controls this behavior. |
|
0 commit comments