Csrf
Cross-site request forgery protection via origin validation
Category: Practical
Task: Cross-site request forgery protection via origin validation
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.
# CSRF Protection
#
# Cross-site request forgery protection via origin
# validation. Safe methods (GET, HEAD, OPTIONS)
# bypass the check. State-changing methods require an
# Origin or Referer header matching the trusted origins.
#
# Sec-Fetch-Site validation provides an additional layer
# of defense: requests with Sec-Fetch-Site: cross-site
# are rejected immediately, before origin matching.
#
# The enforce_percentage option enables gradual rollout:
# set to a value below 100 to enforce CSRF protection on
# only a fraction of requests while monitoring impact.
#
listeners:
- name: default
address: "127.0.0.1:8080"
filter_chains:
- main
filter_chains:
- name: main
filters:
- filter: csrf
trusted_origins:
- "https://app.example.com"
- "https://*.example.com"
enforce_percentage: 100
enable_sec_fetch_site: true
- 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