Two Shiny apps, but can only access one app (other not found)

Hi,

I'm having some difficulty in coding two apps (nsroads and 9c9t) into traefik, receiving a 'Not found' browser response from one of the apps (9c9t app not found).

I'd be grateful for any suggestions.

Best regards,

Richard


Here are the details of the apps:

  1. Path to app:
    application data path 9c9t : /home/shiny/webapps/9c9t
    application data path nsroads: /home/shiny/webapps/nsroads

2.Docker compose file (see contents below).
docker compose file of traefik service : /home/shiny/webapps/9c9t/docker-compose-traefik.yml
docker compose file of 9c9t service : /home/shiny/webapps/9c9t/docker-compose-shinyapp-9c9t.yml
docker compose file of nsroads service : /home/shiny/webapps/nsroads/docker-compose-shiny-nsroads.yml

3.Deploy commands
traefik proxy : root@icem:/home/shiny/webapps/9c9t# docker stack deploy -c docker-compose-traefik.yml proxy_traefik
9c9t stack : root@icem:/home/shiny/webapps/9c9t# docker stack deploy -c docker-compose-shinyapp-9c9t.yml 9c9t
nsroads stack : root@icem:/home/shiny/webapps/nsroads# docker stack deploy -c docker-compose-shiny-nsroads.yml nsroads

4.Networks
traefik : test_net2 & test_net3
9c9t : test_net2
nsroads : test_net3

  1. See attached image from Traefik api

  2. See attached image of 9c9t app 'Not found' response in browser

  3. docker-compose-traefik.yml

     version: "3.7"
      services:
        traefik:
          image: traefik:2.5.3 # also tried traefik:2.4.14
          deploy:
            restart_policy:
              condition: any
            placement:
              constraints:
                - node.role == manager
            labels:
            - "traefik.http.services.traefik.loadbalancer.server.port=80"
            # for https
            - "traefik.http.services.traefik.loadbalancer.server.port=443"
            - "--accesslog.filepath=/var/log/traefik/access.log"
            - "--accesslog.format=json"
            - "--log.level=DEBUG"
            - "--api.insecure=true"
            - "--providers.docker=true"
            - "--providers.docker.swarmMode=true"
            - "--providers.docker.exposedbydefault=false"
            # for http rediect to https
            - "--entrypoints.web.address=:80"
            - "--entrypoints.websecure.address=:443"
            - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
            - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
            # for ssl certificate
            - "--certificatesresolvers.le.acme.httpchallenge=true"
            - "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
            - "--certificatesresolvers.le.acme.email=email_address.com"
            - "--certificatesresolvers.le.acme.storage=acme.json"
            #- --providers.docker.watch=true
          ports:
            - "80:80"
            - "9020:8080"
            - "443:443"
          volumes:
            - "/var/run/docker.sock:/var/run/docker.sock:ro"
          networks:
            - test_net2
            - test_net3
      networks:
        test_net2:
          driver: overlay
          external: true
        test_net3:
          driver: overlay
          external: true
    

docker-compose-shinyapp-9c9t.yml:

     version: "3.7"
     services:
       dataservice:
         image: sustainableos/shiny:9c9t_r4051_ub2004
         #ports:
         #- "3838:3838"
         deploy:
           replicas: 5
           labels:
             - "traefik.enable=true"
             - "traefik.http.routers.dataservice.entrypoints=web"
             - "traefik.http.routers.dataservice.rule= Host(`dev.domain`) && (PathPrefix(`/9c9t`) || PathPrefix(`/`))"
             - "traefik.http.middlewares.dataservice.stripprefix.prefixes=/9c9t,/"
             - "traefik.http.routers.dataservice.middlewares=dataservice@docker"
             - "traefik.http.services.dataservice.loadbalancer.server.port=3838"
             - "traefik.http.services.dataservice.loadbalancer.sticky=true"
             - "traefik.http.services.dataservice.loadbalancer.sticky.cookie.name=stickycookie"
             #- "traefik.http.services.dataservice.loadbalancer.sticky.cookie.secure=false"
             #- "traefik.http.services.dataservice.loadbalancer.sticky.cookie.httpOnly=true"
             # the following for https
             - "traefik.http.services.dataservice.loadbalancer.sticky.cookie.secure=true"
             - "traefik.http.routers.dataservice.entrypoints=websecure"
             - "traefik.http.routers.dataservice.tls=true"
             - "traefik.http.routers.dataservice.tls.certresolver=le"
             #- "traefik.http.middlewares.dataservice.compress=true"
           restart_policy:
             condition: on-failure
           update_config:
             delay: 2s
         volumes:
           - /home/shiny/webapps/9c9t:/home/shiny/webapps/9c9t
         networks:
           - test_net2
     networks:
       test_net2:
         driver: overlay
         external: true

docker-compose-shiny-nsroads.yml

     version: "3.7"
     services:
       nsroads-app:
         image: sustainableos/shiny:nsroads_r362_ub1804
         #ports:
         #- "3838:3838"
         deploy:
           replicas: 5
           labels:
             - "traefik.enable=true"
             - "traefik.http.routers.nsroads-app.entrypoints=web"
             - "traefik.http.routers.nsroads-app.rule=Host(`dev.domain`) && (PathPrefix(`/nsroads`) || PathPrefix(`/`))"
             - "traefik.http.middlewares.nsroads-app.stripprefix.prefixes=/nsroads,/"
             - "traefik.http.routers.nsroads-app.middlewares=nsroads-app@docker"
             - "traefik.http.services.nsroads-app.loadbalancer.server.port=3838"
             - "traefik.http.services.nsroads-app.loadbalancer.sticky=true"
             - "traefik.http.services.nsroads-app.loadbalancer.sticky.cookie.name=stickycookie"
             #- "traefik.http.services.nsroads-app.loadbalancer.sticky.cookie.secure=false"
             #- "traefik.http.services.nsroads-app.loadbalancer.sticky.cookie.httpOnly=true"
             # the following for https
             - "traefik.http.services.nsroads-app.loadbalancer.sticky.cookie.secure=true"
             - "traefik.http.routers.nsroads-app.entrypoints=websecure"
             - "traefik.http.routers.nsroads-app.tls=true"
             - "traefik.http.routers.nsroads-app.tls.certresolver=le"
             #- "traefik.http.middlewares.nsroads-app.compress=true"
           restart_policy:
             condition: on-failure
           update_config:
             delay: 2s
         volumes:
           - /home/shiny/webapps/nsroads:/home/shiny/webapps/nsroads
         networks:
           - test_net3
     networks:
       test_net3:
         driver: overlay
         external: true

hello @richardtc

Thanks for using Traefik and asking the question here :wink:

It does not look like 404 generated by Traefik. Do you have any other HTTP routers / Webservers running on your Dev environment?

The latest available version is 2.6.1 - I highly encourage you to use the latest version, it will not fix the issue you are facing but that version comes with some crucial enhancements.

Additionally, I would try creating a common network .e.g proxy, and use that network on each of your stacks. The network has to be also configured in provider configuration.

1 Like

Your rules are the problem. In short the || PathPrefix(`/`)

Of the two rules: - "traefik.http.routers.nsroads-app.rule=Host(`dev.domain`) && (PathPrefix(`/nsroads`) || PathPrefix(`/`))" has the higher priority due to rule length sorting.

This will match:
https://dev.domain/nsroads.*
then:
https://dev.domain/.*
Your other rule will not get evaluated as the request has already been handled.

If your app is not returning relative links that work with pathPrefix/stripPrefixes then furhter configuration of the app might be required or the use of different rules.