Hello Patrick,
On 08/27/2013 01:54 AM, Patrick Hemmer wrote:
So I'm trying to come up with the best way of doing this, but am having
a heck of a time. Basically I have several different backend service
pools, and I have one externally facing haproxy router. I want to take a
map of public URLs and route them to specific backend URLs.
For example
public.example.com/foo/bar - foo.internal.example.com/one
public.example.com/foo/baz - foo.internal.example.com/two
public.example.com/another - more.internal.example.com/three
So the first 2 public URLs go to the same backend, but need different
rewrite rules.
I've tried doing the following config:
frontend public
acl foo_bar path_dir /foo/bar
reqrep ^([^\ ]*\ )/foo/bar(.*) \1/one\2 if foo_bar
use_backend foo if foo_bar
Except it seems that the foo_bar acl isn't cached, and get's
re-evaluated after doing the reqrep, and so the use_backend fails.
The only way I can think of doing this is to put the acl and the
use_backend in the frontend, and then put the acl again with the reqrep
in the backend. Is there any cleaner way (if it works since I haven't
tried it yet)?
-Patrick
Yes, that's the way to do it - move reqrep part to the backends.
Although, I don't see the need to have 'acl' line in the backend, since
you already matched the ACL in the frontend and 'routed' to the correct
backend where you will do the rewrites:
So something like:
frontend public ...
acl foo path_dir /foo/bar /foo/baz
acl bar path_dir ... ...
use_backend bk_foo if foo
use_backend bk_bar if bar
backend bk_foo
reqrep ^([^\ ]*\ )/foo/bar(.*)\1/one\2
reqrep ^([^\ ]*\ )/foo/baz(.*)\1/two\2
server ...
Regards,
--
Nenad Merdanovic | PGP: 0x423edcb2 | Web: http://nimzo.info
Linkedin: http://www.linkedin.com/in/nenadmerdanovic