Reverse-proxying sub-path to Golang webserver (v2)

I’ve been trying to re-create my NGINX production environment with Caddy for local development. I have an NGINX proxy that proxies Home - Ownwebsite to, e.g. Home - Ownwebsite would proxy to, I would like to replicate that with Caddy…
So far I have this Caddyfile:

reverse_proxy /motorhead/  {

But it gives me a 404 whenever I try to access the /motorhead/ uri even though works fine and returns the correct HTML page. Reverse-proxying to / works but breaks all of my production HREFs…

Thank you for reading!

I think this thread should help you

1 Like

Ah yes, working on this problem today in fact.

I tried:

rewrite /motorhead/ /


rewrite /motorhead/ /
reverse_proxy /

But without any success sadly… I guess if @matt is working on it then I’ll just be patient and work on something else in the meantime, please do let me know when a fix goes live! Finally, let me know if there’s anything I can help with.

Just a heads up - this is a limitation of the Caddyfile (currently, and probably not for much longer), but you should still be quite capable of configuring this if you are willing to go to JSON configuration directly, which will give you much more control.

1 Like

And here’s how to kick-start your JSON from your Caddyfile: Command Line — Caddy Documentation

Does the json parser to any ENV variable replacement?

Substituting env variables is not done at the JSON parsing level. Placeholders are evaluated during module provisioning. Most Caddy modules honor placeholders where you would want them: Conventions — Caddy Documentation

If you find a field that doesn’t support placeholders that should, please let me know or submit a separate PR! :slight_smile:

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