Caddyfile Subdomain with Multiple Proxies

i am new to using caddy and i am trying to figure out how to create a subdomain that can proxy to different endpoints based on path.

for example for a subdomain called pets in the domain i want to route the path /cats to serviceA and /dogs to serviceB.

i have tried this configuration: {
    proxy /cats http://serviceA:80
    proxy /dogs http://serviceB:80

but this does not seem to work.

can anyone see what i am doing wrong?

You don’t say what you mean by “doesn’t work”. Could it be simply that you haven’t removed the “cats” or “dogs” from the URL you pass on? As in:

proxy /cats http://serviceA {
    without /cats
proxy /dogs http://serviceB {
    without /dogs
1 Like

by “doesn’t work” i meant that the redirect doesn’t behave how i expect (i.e. redirect to the proxied endpoint).

i assumed it automatically removed “/cats” or “/dogs” from the URL by default. i have tried your method and now it works!


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