Edit proxied response.Body

Hi all. I’d like to be able edit the response body of a proxied request. The aim, would be to replace all links/requests for insecure assets in a page with either “https://address” or “//address” (I think the latter is sufficient to prevent insecure content warnings in browsers?) This would allow Caddy to front websites and provide TLS without having to revisit the code of each those (older) sites to make the above amends. I can see it’s possible to amend headers up and down stream, is something similar possible for the response body? I am unable to find it in the docs so I suspect not.

Update: This is a very popular search result, but the original answer is outdated. For Caddy 2, please see the replace_response plugin.


Does the http.filter plugin do what you need? https://caddyserver.com/docs/http.filter

I’m sorry - I hadn’t seen that. I was looking at the standard http directives. It looks like it would be perfect. Sorry again :blush:

Edit: It is perfect. A fantastic plugin.

1 Like

It’s fine. Glad it does the trick! There are a lot of third party contributed plugins that do some cool stuff.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.