Gibbz
November 6, 2022, 8:59am
1
I want to use traefik (pi.local) to route to nodered dashboard (pi.local:1880/ui).
Im having trouble getting it working. Currently its changing pi.local to https://pi.local and page not found.
traefik.yml
entryPoints:
http:
address: ":8081"
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
file:
filename: /config.yml
config.yml
http:
routers:
nodered:
entryPoints:
- http
rule: "Host(`pi.local`)"
#middlewares:
# - add-ui
service: nodered
services:
nodered:
loadBalancer:
servers:
- url: "pi.local:1880/ui"
and my docker compose
services:
traefik:
image: traefik:v2.9
container_name: traefik
environment:
- PUID=1000
- PGID=1000
restart: always
ports:
- "80:8081"
- "8080:8080"
network_mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /etc/localtime:/etc/localtime:ro
- /home/pi/Docker/traefik/traefik.yml:/traefik.yml:ro
- /home/pi/Docker/traefik/config.yml:/config.yml:ro
Try adding http://
to loadbalancer URL, see docs .
Gibbz
November 8, 2022, 9:03am
3
I already have http://, im not sure why it has not appeared in my original post.
First I would try removing "ui" from loadbalancer url.
If it still does not work, go into your traefik container and check if you can connect to the other container.
docker exec -it <traefik-container> sh
wget 'http://pi.local:1880'
In general:
Enable Traefik dashboard , debug log and access log to see whats happening.
Gibbz
November 9, 2022, 7:34am
5
Thanks!
I found i can not ping the hostname from within the docker container. Ive changed to the ip address, and made some changes, now its working!
I'll post the complete files for anyone else looking to get it working:
config.yml:
http:
routers:
nodered:
rule: "Host(`pi.local`) || Host(`192.168.1.3`)"
middlewares:
- add-ui
service: nodered
services:
nodered:
loadBalancer:
servers:
- url: "http://192.168.1.3:1880"
middlewares:
add-ui:
addPrefix:
prefix: "/ui"
traefik.yml
# Log level INFO|DEBUG|ERROR
log:
level: DEBUG
api:
dashboard: true
insecure: true
entryPoints:
http:
address: ":80"
web:
address: ":8081"
http:
redirections:
entryPoint:
to: http
scheme: http
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
file:
filename: /config.yml