How to Rewrite URL Paths and Hostnames with Envoy Gateway
This guide shows how to configure Envoy Gateway's URLRewrite filter to transform request prefixes, replace full paths, and rewrite hostnames, providing step‑by‑step YAML examples, kubectl commands, and validation screenshots for microservice integration on Kubernetes.
Scenario 1: Rewrite URL Prefix Path
In a microservice architecture, the frontend may call /api/v1/who while the backend service expects /who. The goal is to let the gateway automatically rewrite /api/v1/who to /who.
cat <<'EOF' | kubectl apply -f -
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: simple
spec:
hostnames:
- example.local
parentRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: simple-gw
rules:
- matches:
- path:
type: PathPrefix
value: /api/v1/who # Browser request path
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: /who # Path seen by the service
backendRefs:
- name: simple
port: 80
EOFApply the manifest with kubectl apply -f - and verify that the service receives the rewritten path.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Linux Ops Smart Journey
The operations journey never stops—pursuing excellence endlessly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
