caddy2-filter
Replace text in HTTP response based on regex. Similar to http.filter in Caddy 1.
Usage
Only the listed fields are supported.
Caddyfile:
# Add this block in top-level settings:
{
order filter after encode
}
filter {
# Only process URL matching this regex
path <optional, regexp pattern, default: .*>
# Don't process response body larger than this size
max_size <optional, int, default: 2097152>
search_pattern <regexp pattern>
replacement <replacement string>
# Only process content_type matching this regex
content_type <regexp pattern>
}
# If you are using reverse_proxy, add this to its config to ensure
# reverse_proxy returns uncompressed body:
header_up -Accept-Encoding
JSON config (under apps › http › servers › routes › handle
)
{
"handler": "filter",
"max_size": <int>,
"path": "<regexp>",
"search_pattern": "<regexp>",
"replacement: "<string>",
"content_type": "<regexp>"
}