I want to post-process HTML output, but I’m having trouble locating the proper syntax or plugin/extension for caddy. I just want to post-process HTML output on one sub-route of a reverse-proxied service. A generic way to pipe through a custom tool would be fine, or something such as a regular-expression matcher/replacer would also work.
That looks sufficiently flexible. Could you tell me how to properly enable it in my Caddyfile? I want it to apply to all HTML output under a particular prefix (/nostrmarket/market in this case).
The Content-Type is ok, and when I moved the template test to the HTML source it worked, so everything Caddy-side is working now as it should. Thank you for your support, and this is probably something I will make good use of in the future, although unfortunately where I needed the template string today is in a dynamically generated part of the page, so I will have to re-think how to solve the problem for my current use case.
This doesn’t do what you think it does. It tries to replace the value of the X-Forwarded header (which isn’t a thing) by searching for the value host and replacing it with satoshidns.com. So effectively, it does nothing. You can probably remove this everywhere.
Using 0.0.0.0 only kinda works “by coincidence”. The IP 0.0.0.0 isn’t a real thing, it means “all interfaces” and is typically used for listen addresses, but as a connection address it happens to connect to “localhost” purely due to a implementation decision by the Linux network stack. See networking - Connecting to IP 0.0.0.0 succeeds. How? Why? - Unix & Linux Stack Exchange. I recommend using 127.0.0.1 or localhost just for clarity’s sake.
These blocks are sorta contradictory. handle_path /* will match every request because all URL paths start with /. So you can just remove the _path /* part of the first block and delete the second handle block and it’ll work the same, with less config.
This can be simplified, you can remove the handle because your rewrite already has the / matcher on it.
Thank you! Your explanations and suggestions are much appreciated!
On that last transport http block, I can only say I think it has to do with the fact that it applies to an API, and the API needs certain behavioral characteristics. I can’t say exactly why at the moment.