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.7.2 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.
# URL Rewriting
#
# Regex-based path transformation and query string manipulation.
#
# Operations execute in declared order:
#
# /v1/users?debug=true&trace=1
# |
# v
# +-------------------------+
# | regex_replace | /v1/users -> /v2/users
# +-------------------------+
# |
# v
# +-------------------------+
# | strip_query_params | ?debug=true&trace=1 -> (empty)
# +-------------------------+
# |
# v
# +-------------------------+
# | add_query_params | -> ?source=gateway
# +-------------------------+
# |
# v
# /v2/users?source=gateway
#
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"
- strip_query_params:
- debug
- trace
- 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