I have a requirement where i have multiple internal services,
e.g
- service1:9000
- service2:9001
- service3:9003
Each service have it's own dynamic path e.g
service1:9000/login?next=%2F,service1:9000/welcome
service2:9001/hub?open=%2F
How do get a route based on the path,
e.g
http://service/path1 => maps to http://service1:9000 + the dynamic urls
http://service/path2 => maps to http://service1:9001 + the dynamic urls
ldez
2
Hello,
http://service1:9000/hub?open=%2F
How an URL is composed:
- scheme:
http
- host:
service1
- port:
9000
- path:
hub
- query:
next=%2F
To define a rule, you can use several matchers:
-
Host(`...`)
to manage the host
-
Path(`...`)
or PathPrefix(`...`)
to manage the path
-
Query(`...`)
to manage query parameters
https://docs.traefik.io/v2.1/routing/routers/#rule
Thank you for the reply.
In case of http://service1:9000 the anything after port is dynamic and i want this to be mapped to
http://service/home/ redirects to http://service1:9000/hub?open=%2F it should return http://service/home/hub?open=%2F
the paths are dynamic here
Is middlewares/replacepathregex equivalent to rewrite