I am currently trying to figure out if the software itself causes the problem or the configuration I wrote in HAProxy, so apologies if it’s not HAProxy related.
I need to redirects to two different services in Docker Swarm, one of them should be selected when the toplevel domain (e.g. institute.org), the other when a subdomain (e.g. internal.institute.org) is used. I am pretty sure it’s a common thing but I get “too many redirects” in the browser, so apparently something goes wild and ends up in an infinite loop.
Here is my latest try
acl ACL_internal.institute.org hdr(host) -i internal.institute.org
acl ACL_institute.org hdr(host) -i institute.org
use_backend be_internal.institute.org if ACL_internal.institute.org
use_backend be_institute.org if ACL_institute.org !ACL_internal.institute.org
and then down the line (but this shouldn’t be the problem)
backend be_institute.org
balance roundrobin
dynamic-cookie-key INSTITUTE
cookie SRVID insert dynamic
option httpchk HEAD /
default-server check maxconn 20
server-template some-service- 1 some-service_foo:80 check resolvers docker init-addr libc,none
backend be_internal.institute.org
balance roundrobin
dynamic-cookie-key OPENDATAKM3NET
cookie SRVID insert dynamic
option httpchk HEAD /
default-server check maxconn 20
server-template some-service- 1 some-service_foo:42023 check resolvers docker init-addr libc,none