Octopus
1.x
Docs/Octopus/Middleware
Open

Reading2 min
Updated31 Jul 2026
Sourcev1/configuration/middleware.mdx

Middleware

Warning

There is no top-level middleware: array in Octopus. The root configuration object has no such field, so a middleware: list at the top level is silently ignored. Middleware behavior is configured through typed fields and the plugin system, described below. (Some older example files show a middleware: array — disregard it.)

How the request pipeline is built01

When the gateway starts it assembles a global middleware chain. Only two middleware are added to that global chain, and only when enabled:

  1. Compression — added when gateway.compression.enabled is true (the default).

  2. Auth gateway — added when any auth_providers are defined or auth.global_enforce is true. This single middleware performs authentication and authorization for every request, honoring the per-route auth fields.

Everything else is configured declaratively on the objects it applies to (the gateway, a route, or an upstream) or supplied through plugins.

Where each behavior lives02

BehaviorWhere it is configured
Compressiongateway.compression — see Gateway.
Authenticationauth_providers + auth (global), plus per-route auth_provider / skip_auth — see Auth.
Authorizationauth.authz (global), plus per-route require_roles / require_scopes / authz_rule — see Auth.
CORSGlobal cors, plus per-route routes[].cors — see Auth and Routes.
Rate limitingPer-route routes[].rate_limit — see Routes.
Request timeoutgateway.request_timeout, overridable per route via routes[].timeout — see Gateway and Routes.
Body size limitgateway.max_body_size — see Gateway.
TLS / mTLS terminationgateway.tls — see TLS.
Health checks / circuit breakingPer-upstream health_check / circuit_breaker — see Upstreams.
Everything elseThe plugins array — see below.

Available middleware implementations03

The octopus-middleware crate ships many more middleware than the two wired into the global chain. These are exposed through the typed fields above and through the plugin system — not through a free-form list. They include: compression, an auth gateway, forward auth, JWT, CORS, rate limiting, circuit breaker, retry, timeout, request/connection limits, IP filtering, a WAF, bot detection, security headers, header and body transforms, request ID injection, request deduplication, response caching, redirects, canary routing, and audit logging.

See the Middleware section for conceptual coverage of each.

Plugins04

The plugins array attaches plugin instances to the gateway. Plugins are the extension point for middleware not covered by the typed fields.

plugins:
  - name: request-id
    plugin_type: static
    enabled: true
    priority: 100
    config:
      header: X-Request-Id
KeyTypeDefaultDescription
namestringPlugin name. Required.
plugin_typestringstaticPlugin type: static or dynamic.
enabledbooleantrueWhether the plugin is active.
priorityinteger0Execution priority — higher runs first.
configmap of string→value{}Plugin-specific configuration (arbitrary JSON values).

See Plugins for authoring and loading plugins.