I am trying to have two web services on the same domain but I am not succeeding. The idea is:
- service_1 is running in container_1 on port 11111
- Service_2 is running in the container_2 on port 2222
- I have the domain abc .com
I want that:
- When accessing abc .com traefik should redirect me to service_1
- When I access abc .com/service2 traefik should redirect me to service_2
For this, this is my current configuration:
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
http:
routers:
service_1_http_to_https:
rule: "Host(`abc .com`)"
entryPoints:
- web
middlewares:
- redirect-to-https
service: noop@internal
service_1:
rule: "Host(`abc .com`) && PathPrefix(`/`)"
entryPoints:
- websecure
tls:
certResolver: le
service: service_1
service_2:
rule: "Host(`abc .com`) && PathPrefix(`/service2`)"
entryPoints:
- websecure
tls:
certResolver: le
middlewares:
- strip-service2
service: service_2
middlewares:
redirect-to-https:
redirectScheme:
scheme: https
strip-service2:
stripPrefix:
prefixes:
- "/service2"
services:
service_1:
loadBalancer:
servers:
- url: "htt p://se rvice_1:11111"
service_2:
loadBalancer:
servers:
- url: "htt p://se rvice_2:22222"
The current behaviour:
- When I try to access abc .com it works fine loading service_1.
- When I try to access abc .com/service2 it loads only the index of service_2.
The problem:
- It turns out that when I access abc .com/se rvice2 and it requests a module from service_2, it is requesting it from service one, since for example, to import myjavamodule.js it requests it to abc .com/myjavamodule.js which looks for it in service_1 totally different when it should do it to abc .com/se rvice2/myjavamodule.js which should call htt p://se rvice_2:22222/myjavamodule.js
How can I in this case keep the two services totally separate using the same domain?