How to proxy to different services according to different url paths

This is my Caddyfile:

localhost:1234 {
	root /www
	index index.html
}
localhost:1235 {
	root /www/a
	index index.html
}
localhost:1236 {
	root /www/b
	index index.html
}
:2019 {
	proxy / localhost:1234 {
		except /a /b
	}
	proxy /a localhost:1235
	proxy /b localhost:1236
}

the external leak port is 2019, then I want to got this:

// ===>>> means proxy to
localhost:2019 ===>>> localhost:1234
localhost:2019/a ===>>>  localhost:1235
localhost:2019/b ===>>> localhost:1236

I tried a lot of methods, it doesn’t work, please help me.

Hi @1115, welcome to the Caddy community.

You’ve told us what you tried, which is good, but could you please elaborate on:

  • What HTTP requests you’re making
  • What result you’re expecting
  • What result you get instead

Include specific error messages, please.

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