My marathon-lb configuration:
"labels": {
"HAPROXY_GROUP": "external",
"HAPROXY_0_VHOST": "test.com",
"HAPROXY_0_MODE": "http"
}
I want it route only requests like test.com/12345
to internal endpoint
/results?q=123
. How to achieve that?
P.S. Nginx rule for the same purpose looks like:
location ~* /[\w\-]+?$ {
proxy_pass http://127.0.0.1:8094;
rewrite ^/([\w\-]+?)$ //results?q=$1? break;
}
As you probably know marathon-lb is HAProxy plus some wrappers. You can add a redirect to HAProxy configuration, by using HAPROXY_0_BACKEND_HTTP_OPTIONS label. There's a legacy reqrep statement which you may find convenient and you can also go for 301 redirect. For example you can do:
"HAPROXY_0_BACKEND_HTTP_OPTIONS": " reqrep ^/([\w\-]+?)$ /results?q=\\1 \n",
or
"HAPROXY_0_BACKEND_HTTP_OPTIONS": " acl is_foo path -i /foo \n redirect code 301 location /bar if is_foo\n",
Note double spaces for indent. Not that you'll have to play with escapes to make it work.