pplmx
March 19, 2023, 4:58am
1
Here is my trial. It doesn't work. I cannot access the dashboard by http://traefik.local
.
Could anyone give me some help? Thanks a lot.
version: Compose specification
services:
traefik:
image: traefik:2.9
ports:
- "80:80"
- "8080:8080"
volumes:
- "./traefik.toml:/etc/traefik/traefik.toml"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
[log]
level = "INFO"
[api]
dashboard = true
insecure = true
[providers.docker]
exposedByDefault = false
[entryPoints]
[entryPoints.web]
address = ":80"
[http.routers]
[http.routers.dashboard]
rule = "Host(`traefik.local`)"
service = "dashboard@internal"
[http.routers.api]
rule = "Host(`traefik.local`) && PathPrefix(`/api`)"
service = "api@internal"
I don’t think there is dashboard@internal, it’s all api@internal.
Also routers and services need to go into dynamic configuration, which is loaded by a provider like file or docker.
See dashboard routing in the docs :
# Dynamic Configuration
labels:
- "traefik.http.routers.dashboard.rule=Host(`traefik.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
- "traefik.http.routers.dashboard.service=api@internal"
- "traefik.http.routers.dashboard.middlewares=auth"
- "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"
See simple example of Traefik docker-compose.yml
.
pplmx
March 19, 2023, 1:50pm
3
Hi, @bluepuma77
I directly run your simple example of Traefik, I still cannot access http://traefik.example.com
I also tried:
pplmx
March 19, 2023, 2:32pm
4
Here is my latest traefik.yml. It still doesn't work.
### Static Configuration
log:
level: INFO
api:
insecure: true
entryPoints:
web:
address: :80
providers:
docker:
exposedByDefault: false
file:
# location in traefik container
filename: /etc/traefik/traefik.yml
---
### Dynamic Configuration
http:
routers:
dashboard:
rule: Host(`traefik.local`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))
service: api@internal
priority: 1000
entryPoints:
- web
api.insecure:true
will automatically run Dashboad on :8080
.
Use
api:
# Dashboad
dashboard: true
And note:
The trailing slash /
in /dashboard/
is mandatory
1 Like
pplmx
March 19, 2023, 3:35pm
6
Not work. >_<. I am using the Windows, could this be the cause of the problem?
I had the same problem before, but was finally able to solve it.
First of all, you need to add the network in Docker if you add it externally like I did (it's so you can add other services there as well and Traefik will recognize them).
docker-compose.yml
version: '3'
services:
reverse-proxy:
image: traefik
container_name: "traefik"
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik:/etc/traefik
labels:
- traefik.http.routers.traefik.rule=Host(`traefik.local`)
- traefik.http.routers.traefik.service=traefik@docker
- traefik.http.services.traefik.loadbalancer.server.port=8080
# - traefik.http.routers.traefik.tls.certresolver=lets-encrypt
networks:
- proxy
- default
networks:
proxy:
external: true
default:
driver: bridge
traefik.yml
providers:
docker:
watch: true
network: proxy
ping:
manualRouting: true
log:
filePath: "/etc/traefik/logs/log-file.log"
level: "ERROR"
accessLog:
filePath: "/etc/traefik/logs/access.log"
api:
dashboard: true
insecure: true
## Static configuration
entryPoints:
web:
address: ":80"
Have you set up traefik.local
in your hosts file or DSL routers DNS? What happens when you ping traefik.local
?
What happens when you access http://traefik.local/dashboard/
?
Enable Traefik debug log and access log .
pplmx
March 20, 2023, 2:02am
9
Using your case, Still NOT. >.<
pplmx
March 20, 2023, 2:08am
10
I don't config /etc/hosts
:
ping: traefik.local: Name or service not known
I hope access traefik dashboard http://127.0.0.1:8080
by http://traefik.local
.
If without additional DNS service, Can this be achieved with traefik alone?
TODO:
Port Mapping: 8080->80
DNS: 127.0.0.1->traefik.local
pplmx
March 20, 2023, 2:10am
11
I found this sample, it can access http://whoami.docker.localhost
on the Browser.
version: '3'
services:
reverse-proxy:
# The official v2 Traefik docker image
image: traefik:v2.9
container_name: reverse_proxy
# Enables the web UI and tells Traefik to listen to docker
command: --api.insecure=true --providers.docker
ports:
# The HTTP port
- "80:80"
# The Web UI (enabled by --api.insecure=true)
- "8080:8080"
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
# ...
whoami:
# A container that exposes an API to show its IP address
image: traefik/whoami
container_name: reverse_whoami
labels:
- "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"
pplmx
March 24, 2023, 5:57am
12
traefik is not a DNS server. So configuring the /etc/hosts or other DNS server(e.g. adguardhome, dnsmasq) is needed.
Here is my final config:
127.0.0.1 traefik.m.local
version: Compose specification
services:
traefik:
image: traefik:2.9
ports:
- "80:80"
- "8080:8080"
volumes:
# /traefik.yml and /etc/traefik/traefik.yml are both available.
- "./traefik.yml:/etc/traefik/traefik.yml"
# dynamic-conf dir is self-defined
- "./dynamic-conf:/etc/traefik/dynamic-conf"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
- traefik-net
networks:
traefik-net:
name: traefik-net
ipam:
config:
- subnet: 172.16.238.0/24
static configuration: traefik.yml
### Static Configuration
log:
level: DEBUG
api:
insecure: true
dashboard: true
entryPoints:
web:
address: :80
providers:
file:
# location in traefik container
# filename: /traefik.yml
directory: /etc/traefik/dynamic-conf
dynamic configuration in dynamic-conf
dir: self.yml
### Dynamic Configuration
http:
routers:
dashboard:
rule: Host(`traefik.m.local`)
service: api@internal
system
Closed
March 27, 2023, 5:57am
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.