A3S GatewayMiddleware
Strip Prefix
Remove path prefixes before forwarding, including a /* single-segment wildcard
Strip Prefix
strip-prefix rewrites the request path before forwarding by removing the first matching configured prefix.
Behavior
Prefixes are checked in list order:
- Normal prefix:
/api/v1matches paths beginning with/api/v1. - Single-segment wildcard:
/apps/*strips/apps/plus exactly one dynamic segment.
If the remaining path is empty, it becomes /. Query strings are preserved.
Configuration
middlewares "strip-api" {
type = "strip-prefix"
prefixes = ["/api/v1", "/api/v2"]
}
middlewares "strip-app" {
type = "strip-prefix"
prefixes = ["/apps/*"]
}| Key | Type | Default | Notes |
|---|---|---|---|
type | string | required | Must be strip-prefix. |
prefixes | array<string> | [] | First match wins; empty means pass-through. |
Examples
| Original path | Config | Upstream path |
|---|---|---|
/api/v1/users?page=1 | /api/v1 | /users?page=1 |
/api/v1 | /api/v1 | / |
/apps/asset-123/api/meta | /apps/* | /api/meta |
Notes
- Order matters; put more specific prefixes first.
/*is one dynamic segment, not a greedy wildcard.- If Forward Auth needs the original path, put auth before stripping.
Recommended Order
middlewares = ["auth-jwt", "rate-limit", "strip-prefix"]