I would like to add another docker container to an existing traefik environment. The first app handles all http and https requests with the following docker-compose configuration:
I would like to add the second app, which would be targeted by hostname.com/app/. However, the following configuration does not work. Still the first app responses with 404 error:
Please let me know how to solve the problem.
From the documentation: (https://docs.traefik.io/v2.1/routing/routers/#priority), priority is an ordered number.
Therefore priority 100 will match before priority 1.
By setting your second service to a priority of 1, every other service will be matched first.
Try it with a priority of 100.
Thank You for the quick reply but the change of priority does not help.
I assume this is a typo and should be /xnat/
- Your routers lime-https and xnat need tls enabled.
- The priority was an issue.
- You likely want a
(Host(`hostname.com`) && Path(`/xnat/`)) rule.
traefik.http.routers.xnat.service is not required, it is implicit from the docker service/container
Thank You for the responses. Indeed I have copied configuration from the first app and modified the names. Also I have added priority and it seems to work. However, I have an additional question regarding my application. What if hostname.com/app redirects to eg. hostname.com/login for authorisation. Can Traefik handle such requests?
The app is sending the redirect? Update an existing rule to match it or add a new route/service.
Same app handles uri
.....rule=(Host(`hostname.com`) && (Path(`/xnat/`) || Path(`/login`)) )
If another service does
/login then the same pattern of adding traefik labels for a new router.