Multi Data Center Apps

We have microservices running from one datacenter planning to go in active-active setup, i mean in multi-dc setup. Note no cloud is involved here and we are only looking for on-prem setup.

We need to setup as below.

LB (1.1.1.1) --> /web (goes to 2.2.2.2 port 80 in dc1 and 3.3.3.3 port 80 in dc2 with session persistence)
--> /api (goes to 4.4.4.4 port 80 in dc1 and 5.5.5.5 port 80 in dc2)

Is it possible to achieve this with traefik proxy?

Traefik is a reverse proxy, it should be reachable through the Internet at some IP. It can then forward requests by hostname and/or path prefix to target services.

If you want to configure targets manually, this can be done with a dynamic config file, loaded in static config with providers.file (doc).

Just set up a router to match the request and a service to forward to multiple target hosts. Forward will be round-robin or can be sticky by cookie.

Ok so for dc1 i will have traefik proxy and for dc2 another instance of traefik proxy. On top of this, we will have dns loadbalancer, so how should we failover service in case a service goes down in dc1. For example /web goes down in dc1. So dns load balancer should notified about /web failure, how this will work, can you please let me know your thoughts?

Because having single traefik proxy in only either of datacenter in true sense is not active active mode.

Check Traefik retry middleware (link).

We use a LB from the hoster, run multiple Traefik in parallel behind it, which again do LB to the target service.

Will this help, also when the main site is healthy will it revert the traffic to to main site automatically?

Not sure what you mean. Traefik has an entrypoint on the port, has a router to match domain/path, optionally applies middlewares and then uses service to forward the request.

I mean instead of using middleware that you suggested, I can directly use out of box service called failover to achieve my goal of failovering service in dc1 to dc2 until dc1 gets healed