Header Manipulation
Add, overwrite, and remove headers on requests and responses
Category: Practical
Task: Add, overwrite, and remove headers on requests and responses
Prerequisites: The product runtime and any backend services referenced by this configuration.
This configuration comes from the selected release. The example has not been run here; external services are not bundled.
Download the source file.
# Header Manipulation
#
# Add, overwrite, and remove headers on requests and responses.
#
# Usage:
# cargo run -p praxis-proxy -- -c examples/configs/transformation/header-manipulation.yaml
# curl -v http://localhost:8080/
#
# Request to upstream gains: X-Forwarded-By, X-Request-Source.
# Response to client gains: X-Powered-By, X-Frame-Options, X-Request-Served-By.
# Server header is stripped from responses.
#
# response_add vs response_set:
# response_add appends (preserves existing values);
# response_set overwrites any existing value.
listeners:
- name: default
address: "127.0.0.1:8080"
filter_chains:
- main
filter_chains:
- name: main
filters:
- filter: router
routes:
- path_prefix: "/"
cluster: backend
- filter: headers
request_add:
- name: "X-Forwarded-By"
value: "praxis"
- name: "X-Request-Source"
value: "gateway"
response_add:
- name: "X-Request-Served-By"
value: "praxis-gateway"
response_set:
- name: "X-Powered-By"
value: "praxis"
- name: "X-Frame-Options"
value: "DENY"
response_remove:
- "Server"
- filter: load_balancer
clusters:
- name: backend
endpoints:
- "127.0.0.1:3000"
insecure_options:
allow_private_endpoints: true # example proxies to local backends