explaingit

caddyserver/replace-response

Analysis updated 2026-07-08 · repo last pushed 2025-06-18

156GoAudience · ops devopsComplexity · 2/5StaleLicenseSetup · moderate

TLDR

A Caddy module that finds and replaces text in web pages or API responses as they pass through your server, without touching the original backend application.

Mindmap

mindmap
  root((repo))
    What it does
      Finds and swaps text
      Modifies responses on the fly
      Simple or pattern matching
      Targets HTML or JSON
    How it works
      Sits between users and apps
      Intercepts outgoing responses
      Two modes available
    Use cases
      Company rebranding
      Fix typos live
      Rewrite URLs on the fly
      Insert dynamic values
    Limitations
      Cannot modify compressed content
      Skips matches over 2 kilobytes
      Streaming drops size info
    Tech stack
      Go
      Caddy server
      Reverse proxy module
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Swap an old brand name across multiple backend services without redeploying them.

USE CASE 2

Rewrite embedded URLs during a domain migration on the fly.

USE CASE 3

Update a copyright year or fix a typo in responses without touching the original app.

USE CASE 4

Insert dynamic values like the current hostname or client IP into responses.

What is it built with?

GoCaddy

How does it compare?

caddyserver/replace-responsevadimsemenykv/saboteurimshire/xu-shop
Stars156157140
LanguageGoGoGo
Last pushed2025-06-18
MaintenanceStale
Setup difficultymoderateeasyhard
Complexity2/53/54/5
Audienceops devopsdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires building Caddy with the module using xcaddy and disabling backend compression for the module to work.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

The replace_response module for Caddy lets you automatically find and swap text in web pages or API responses as they pass through your server. Imagine you want to change a brand name everywhere it appears, update a copyright year, or fix a typo without touching the original backend application, this tool handles that on the fly. Caddy is a web server that sits between users and your applications. Normally it just forwards requests and responses, but with this module added, it intercepts outgoing responses and performs text substitutions before they reach the user. You can do simple find-and-replace operations or use more powerful pattern matching. You can also target specific types of responses, like only modifying JSON data or only HTML pages. This is useful for anyone running Caddy as a reverse proxy. A company rebranding might need to swap an old product name across multiple backend services without redeploying them. Someone migrating domains could rewrite embedded URLs on the fly. You can also use Caddy's built-in variables to dynamically insert things like the current hostname or client IP into responses. The module offers two operating modes. By default it buffers the entire response first, which is less memory-efficient but ensures the response size metadata stays accurate. Alternatively, streaming mode processes data as it flows through, which is faster but may drop that size information since the final length is unknown ahead of time. There are some limitations worth noting. It cannot modify compressed content directly, you need to tell the backend not to compress responses first. Additionally, pattern matches longer than 2 kilobytes will be skipped. These constraints matter when deciding whether this approach fits your use case.

Copy-paste prompts

Prompt 1
Write a Caddyfile configuration that uses the replace_response module to swap every occurrence of 'OldBrand' with 'NewBrand' in HTML responses from my reverse proxy backend.
Prompt 2
Set up Caddy with replace_response to rewrite all URLs in API JSON responses from old-domain.com to new-domain.com, including configuration to disable backend compression.
Prompt 3
Create a Caddyfile that uses replace_response in streaming mode to dynamically insert the client's IP address into an HTML page, and explain when streaming mode is better than buffered mode.
Prompt 4
Help me add the replace_response module to my existing Caddy build using xcaddy, and write a config that replaces a typo in responses only for JSON content types.
Prompt 5
Explain the 2 kilobyte pattern match limit in replace_response and write a config that avoids hitting it when doing multiple text substitutions.

Frequently asked questions

What is replace-response?

A Caddy module that finds and replaces text in web pages or API responses as they pass through your server, without touching the original backend application.

What language is replace-response written in?

Mainly Go. The stack also includes Go, Caddy.

Is replace-response actively maintained?

Stale — no commits in 1-2 years (last push 2025-06-18).

What license does replace-response use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is replace-response to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is replace-response for?

Mainly ops devops.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.