Skip to main content

StripPrefix

Removing prefixes from the path before forwarding the request.

The StripPrefix middleware strips the matching path prefix and stores it in a X-Forwarded-Prefix header.

tip

Use a StripPrefix middleware if your backend listens on the root path (/) but should be exposed on a specific prefix.


Configuration Options

prefixes

FieldDescription
prefixesThe prefixes option defines the prefixes to strip from the request URL.

If your backend is serving assets (for example, images or JavaScript files), it can use the X-Forwarded-Prefix header to construct relative URLs.

Example

Strip prefix /foobar and /fiibar
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: test-stripprefix
spec:
stripPrefix:
prefixes:
- /foobar
- /fiibar