Header Transformations
Header transformations allow you to modify HTTP headers in both requests and responses. This feature is useful for security, compatibility, and customization purposes.
Configuration Structure
transformation:
request_headers:
- name: content-type
action: remove
enabled: true
- name: user-agent
action: set
value: this_is_a_test_user_agent
enabled: true
response_headers:
- name: content-type
action: remove
enabled: true
- name: user-agent
action: set
value: this_is_a_test_response_header
enabled: true
Configuration Options
Request Headers
- Type: Array
- Description: List of transformations to apply to request headers
Response Headers
- Type: Array
- Description: List of transformations to apply to response headers
Header Transformation Options
Name
- Type: String
- Required: Yes
- Description: Name of the header to transform
- Example:
name: "content-type"
Action
- Type: String
- Required: Yes
- Options:
remove
,set
,add
- Description: Action to perform on the header
remove
: Remove the headerset
: Set or replace the header valueadd
: Add the header if it doesn't exist- Example:
action: "remove"
Value
- Type: String
- Required: When action is
set
oradd
- Description: Value to set for the header
- Example:
value: "application/json"
Enabled
- Type: Boolean
- Default:
true
- Description: Whether the transformation is active
- Example:
enabled: true
Best Practices
- Use specific header names
- Test transformations in a staging environment
- Document header changes
- Monitor for unexpected behavior
- Keep transformations organized
Example Configurations
Basic Header Transformations
transformation:
request_headers:
- name: "x-forwarded-for"
action: remove
enabled: true
- name: "user-agent"
action: set
value: "Custom User Agent"
enabled: true
response_headers:
- name: "server"
action: remove
enabled: true
- name: "x-frame-options"
action: set
value: "DENY"
enabled: true
Security Headers
transformation:
response_headers:
- name: "x-content-type-options"
action: set
value: "nosniff"
enabled: true
- name: "x-xss-protection"
action: set
value: "1; mode=block"
enabled: true
- name: "strict-transport-security"
action: set
value: "max-age=31536000; includeSubDomains"
enabled: true
Common Use Cases
- Security Headers: Add security-related headers
- Compatibility: Modify headers for compatibility
- Privacy: Remove sensitive headers
- Customization: Set custom header values
- Standardization: Ensure consistent header values