Cloud Native 4 min read

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.

Linux Ops Smart Journey
Linux Ops Smart Journey
Linux Ops Smart Journey
How to Rewrite URL Paths and Hostnames with Envoy Gateway

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
EOF

Apply the manifest with kubectl apply -f - and verify that the service receives the rewritten path.

CloudNativeKubernetesAPIgatewayEnvoyURLRewrite
Linux Ops Smart Journey
Written by

Linux Ops Smart Journey

The operations journey never stops—pursuing excellence endlessly.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.