Use Caddy Exec Output for routing

Hello,
I am currently calling a script that outputs a port number (in stdout) using the exec plugin. I ideally want to use this port number with the reverse proxy directive. The issue is that the exec plugin simply returns status success and is not giving me a chance to use it’s output for caddy routing. I have also tried the cgi plugin but it isn’t allowing me to route the user either.
Requesting help/ideas for the same.

This sounds like a feature request. Probably best if you ask for help on that plugin’s GitHub repo. I’m not sure exactly which plugin you’re using, there’s more than one exec plugin.

Alternatively, you could fork the plugin and implement the functionality you need. We can help you with that if you have specific questions.

I am using ‘caddy-exec’ plugin, sorry didn’t know there were multiple (will keep an eye out for the others).
I could fork the caddy-exec repo but I don’t know how caddy would accept the returning data and pass it to the next directive. If you have some resource explaining it - please share
Thanks for the prompt response

You can set variables in the request context. Look at the vars directive in Caddy’s source (VarsMiddleware) which does this as well. Then you can use placeholders later in your config to reuse those values.

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