I'm trying to create multiple nodeJS apps stored on the same subdomain.
I'm managing those actions using ocker-compose. and for some reason i have an error while trying to use more then one middleware.
when I'm trying to use "replace regex" and "prefix strip" at the same time, it looks like only one of them is activating and the one written the last is overrides the first one.
@suxarik note that you do not have to use chain for multiple middlewares. According to the link you provided this is mostly to be able to re-use the same sequence of middlewares in multiple place. If you only use them in a single place, the chain is not useful.
Hi ! , I tried with the link given for the correct answer. But I think Im going somewhere wrong with my configuration.
I already have a main app running as a service on the main domain. say : https://abc.com
My intentions is to host another app as a different service on https://abc.com/app2
I have pasted both the service labels here.
Thanks for the solution. I removed the PathPrefix. and added the two stripprefix middleware. Now the abc.com also opens up app2 instead of mainapp.
I am looking to have the main app on abc.com and the app2 on abc.com/app2
Hi, you still need to keep the PathPrefix.
The PathPrefix rule and the stripprefix middleware serve completely different purposes.
The PathPrefix rule is used to route all request within /app2 to to your app2 service.
The stripprefix middleware modifies the request presented to the service app2.
If you call htts://abc.com/app2/test.html without stripprefix, then Traefik sends an request for /app2/test.html to app2. But with stripprefix Traefik sends an request for /test.html to app2, thus removing the /app2/ component.
It might or might not work - depending on how app2 creates links. If app2 use absolute links like https://abc.com/css/style.css instead of a relative css/style.css, then it will not work, as those requests still will be send to app1.
Thanks much for explaining. understood it better now.
So now, here is my config, but still getting 404. The mainapp on a different stack, works fine on main domain . The maindomain/app2 throws 404. I'm trying to give more thoughts to this..
now only issue is on the browser the /app2/ renders the app correctly but if only /app2 in the address doesn't renders the css. I have to add / to ensure that app renders correctly. Any clues to solve this issue ?