Examples
Url Rewriting
Regex-based path transformation and query string manipulation
Category: Practical
Task: Regex-based path transformation and query string manipulation
Prerequisites: The product runtime and any backend services referenced by this configuration.
Run it: Use ghcr.io/praxis-proxy/praxis:0.8.0 and follow the first reverse-proxy tutorial to mount and start the configuration.
This configuration comes from the selected release. The example has not been run here; external services are not bundled.
Download the source file.
Companion resources from the same snapshot:
# URL Rewriting
#
# Regex-based path transformation and query string manipulation.
#
# Operations execute in declared order:
#
# /v1/users?api-version=2024-01&user=alice&debug=true
# |
# v
# +------------------------------+
# | regex_replace | /v1/users -> /v2/users
# +------------------------------+
# |
# v
# +------------------------------+
# | preserve_query_params_only | keeps only api-version and user
# +------------------------------+
# |
# v
# +------------------------------+
# | add_query_params | appends source=gateway
# +------------------------------+
# |
# v
# /v2/users?api-version=2024-01&user=alice&source=gateway
#
# preserve_query_params_only is an allowlist: keep only these params, drop
# everything else. For targeted removal use strip_query_params (a denylist).
# See url-rewriting-preserve.yaml for a focused preserve example.
#
listeners:
- name: default
address: "127.0.0.1:8080"
filter_chains:
- main
filter_chains:
- name: main
filters:
- filter: url_rewrite
operations:
- regex_replace:
pattern: "^/v1/(.*)"
replacement: "/v2/$1"
- preserve_query_params_only:
- api-version
- user
- add_query_params:
source: gateway
- filter: router
routes:
- path_prefix: "/"
cluster: backend
- filter: load_balancer
clusters:
- name: backend
endpoints:
- "127.0.0.1:3000"
insecure_options:
allow_private_endpoints: true # example proxies to local backends