HTTPS backend API call on exposed port 8080 just return 404

Hi all, iam very very new to traefik and need some help with my problem:
I have a Traefik setup with just a frontend (served via https on port 443 -> works!) and a backend on port 8080. This does not work and i really dont understand why?? There is no issue on the application layer, there has to be a configuration issue on my side regarding traefik :frowning: My frontend need to make API calls via https! My code for workink frontend:

version: '3'
services:
   frontend:
      image: nginx:latest
      volumes:
        - ./dist:/usr/share/nginx/html
        - ./nginx_conf/nginx.conf:/etc/nginx/conf.d/default.conf
      networks:
         - default
         - web
      labels:
         - traefik.enable=true
         - traefik.http.routers.frontend.rule=Host(`my-domain.info`)
         - traefik.http.routers.frontend.tls=true
         - traefik.http.routers.frontend.tls.certresolver=lets-encrypt
         - traefik.http.services.frontend.loadbalancer.server.port=443 # on 443 nginx is listening
networks:
   web:
      external: true

So if i call: https://my-domain.info, the frontend listening on port 443 gets triggered. Perfect!
My code on not working backend:

version: '3'
services:
   backend:
      image: node:latest
      volumes:
        - ./dist:/usr/src/app    
      networks:
         - default
         - web
      labels:
         - traefik.enable=true
         - traefik.http.routers.backend.rule=Host(`my-domain.info/backend`)
         - traefik.http.routers.backend.tls=true
         - traefik.http.routers.backend.tls.certresolver=lets-encrypt
         - traefik.http.services.backend.loadbalancer.server.port=8080
      command: node /usr/src/app/index.js
networks:
   web:
      external: true

The node server is listening on port 8080, but doest get triggered. I just get an 404 :frowning:
I have also tried my-domain.info:8080 as well as a subdomain. Nothing works.
Strange because i basically copied the logic from frontend config to backend

So the traefik setup looks like this:

version: '3'
services:
   traefik:
      restart: unless-stopped
      image: traefik:latest
      networks:
         - web
      ports:
         - "80:80" 
         - "443:443" #frontend
         - "8080:8080"
      volumes:
         - /var/run/docker.sock:/var/run/docker.sock:ro
         - ./acme.json:/acme.json
         - ./traefik.yml:/traefik.yml
         - ./traefik_api.yml:/traefik_api.yml
networks:
   web:
      external: true

So the refered traefik.yml looks like this (maybe there is some error?!) Iam no sure if i have to add something to the entryPoint configuration for backend?

entryPoints:
   web:
      address: ':80'
      http:
         redirections:
            entryPoint:
               to: websecure
               scheme: https
   websecure:
      address: ':443'
   backend:
      address: ':8080'
api:
   dashboard: true
certificatesResolvers:
   lets-encrypt:
      acme:
         email: my-email@gmx.de
         storage: acme.json
         tlsChallenge: {}
providers:
   docker:
      watch: true
      network: web
      exposedByDefault: false
   file:
      filename: traefik_api.yml

The remaining traefik_api.yml is just for the dashboard. This one works fine.

I would appreciate any help very much, because i dont understand, why a https://my-domain.info/backend returns a 404. But it is secured, so the TLS stuff seems to be fine. Let me know, if you need any further information.

What i just need at the end is, that my frontend can make https://my-domain.info/routes ... and traefik routes these calls to the corresponding backend, which contains these routes.
Best, Marc

I don't think you can include the path in the Host rule. You should try:

- traefik.http.routers.backend.rule=Host(`my-domain.info`) && Path(`/backend`)

You can also adding debug logging to your traefik.yml to look for errors. Actually I think you will see the issue I mentioned in your traefik log without even setting debug - check docker logs traefik

log:
  level: DEBUG

Hi youngt2,

thank you very much for your replay.

I have tried to add the && Path(/backend)
but it did not solve the issue. Still 404

Regarding the logging i could also not make it work. Where exactly is the place for log keyword?

I have tried this

set all up like it is describled there...but nothing gets logged. Sorry iam a newbie. But i would appriciate it very much, if you could just give me a hint where do add the log keyword. Could not find it in the official documentation.

Does your backend node app respond on path backend? Use PathPrefix() instead of Path().

Hi, i have changed the Path() to PrefixPath(), as you suggested.
Host(my-domain) && PathPrefix(/backend)

It returns Cannot GET /backend/, when i try to access this in the browser.

Well, regarding your question. If i expose the backend beside the proxy, i can access it from serverIPv4:8080 and it works fine. But once this is living behind the proxy i cant get it to run :frowning: i have really no idea whats wrong

I thought this line is responsible for the response:

  • traefik.http.services.backend.loadbalancer.server.port=8080

and the backend is running and listening on port 8080 as well

I think Cannot GET /backend/ is rather telling you that you can not use GET, but should use another method like POST. That is rather an application error, not Traefik.

Enable Traefik access log in JSON format to see which service is throwing the error (Traefik or target app).

loadbalancer.server.port=8080 tells Traefik to route forwarded requests to this port within the target container.

well actually it is working now...i had a testing route i node js which was unfortunately:
app.get('/', (req, res) => {
res.send('Node js response successfull')
});

and this was not triggered behind the proxy.

I have changed the route to something else and suddenly node is responsing.

Thank you all for your help guys...jesus this stuff kicks asses