FFFcat / caddy2-filter

Replace response body in caddy2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

caddy2-filter

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. GoDoc Go Report Card

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>"
}

About

Replace response body in caddy2

License:Apache License 2.0


Languages

Language:Go 77.5%Language:Roff 12.0%Language:Shell 10.5%