0

I have an application that I wish to deploy on path: www.example.com/foo I have another application that I want to deploy on path: www.example.com/bar

My load balancer currently doesn't support that.

How do I accomplish that? I read about path_beg but I can't seem to grasp it correctly. Is there an example that I can follow?

1 Answers1

0

It's pretty straightforward.

frontend main-frontend
  mode http
  bind :80
  use_backend foo-backend if { path_beg /foo }
  use_backend bar-backend if { path_beg /bar }

Then you'd need to declare 2 backends, named "foo-backend" and "bar-backend" pointing to the servers and ports where those apps are listening (could be different servers, or just different ports on the same back-end servers). The names of the backends don't have to have "foo" and "bar" in them, as long as they match the names in the "use_backend" statements.

With this setup, the back-end servers need to be expecting the /foo or /bar at the beginning of the incoming path, because the entire request-path will be forwarded.

It is possible for haproxy to rewrite the path to scrub those out, but that configuration is rather more advanced.

Michael - sqlbot
  • 169,571
  • 25
  • 353
  • 427