0

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 my-website.com. i want to route the path /cats to serviceA and /dogs to serviceB.

i have tried this configuration:

pets.my-website.com {
    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?

X0r0N
  • 1,816
  • 6
  • 29
  • 50

1 Answers1

0

the problem was caused because the path it was forwarding to the service included the url path prefix. e.g. /cats.

i thought it would automatically remove this prefix but it doesnt. the solution is as follows:

pets.my-website.com {
    proxy /cats http://serviceA:80 {
        without /cats
    }
    proxy /dogs http://serviceB:80 {
        without /dogs
    }
}
X0r0N
  • 1,816
  • 6
  • 29
  • 50