Reverse Proxy Analyzing Files Content: Plugin, Config or Other?

Hi.

I have an idea of serving static content from IPFS http-gateway at localhost:8080.
Caddy will be used as a reverse proxy that not only rewrites URL path but also for every file analyzes if it’s a text file with content starting with some magic prefix like IPFS_REDIRECT 307 ./../another_sub_folder/some_other_file.

IPFS gateways inherently don’t support http redirects and in this project I want to provide this facility for the purpose of hosting static content at some custom domain name via IPFS. And if content owner decides he want to move his stuff from https://example.com/same_sub_folder/foo.app to https://example.com/same_sub_folder/bar.exe then he just replaces /ipns/example.com/same_sub_folder/foo.app with a text file /ipns/example.com/same_sub_folder/foo.app but with a specific magic prefix inside and Caddy should pick it up, parse it and provide a redirect.

I’m totally new to Caddy so I ask for a general guidance and an advice like should I write a plugin or just a config file.

1 Like

Hi @ilyaigpetrov, welcome to the Caddy community.

There isn’t any functionality in the proxy directive currently that would allow you to configure it to parse the upstream response body and issue a redirect downstream depending on the result.

To provide this capability you might need to look at extending Caddy specifically for this purpose - whether that’s by modifying the proxy plugin or by writing a custom plugin of some kind.

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