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 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
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