Reverse_proxy. select backend by incoming path

Hello guys!

I’m totally new here, and I would like to ask a question about a pretty specific problem

in a reverse_proxy config, Is it possible to select the backend from a key-value store? any dynamic backend would do

in my scenario, the backends are not the same, and I need templated input matcher, where the template emits parts of the pattern for future use

I need something like:

incoming pattern: ^https://(?P[\w.]+)/(?Pdevice\d+)/(?P.*)$ → lookup (device) in a key-value store, and proxy the request to http://value/(path)

The most flexible option is to implement a dynamic upstreams module. That would let you do any logic you need to parse the URL and do a lookup in your KV store for the correct upstream to use. See Extending Caddy — Caddy Documentation to learn how to write plugins for Caddy. Look at Caddy’s source code to see how the existing dynamic upstreams modules are implemented, you can pretty much copy-paste one of those as your starting point.

thanks a lot! I have a lot to learn about caddy, good to know that I can have some support here :slight_smile:

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