Hi all.
My DNS A record is ws-traefik.wslan and it is pointing to the IP of the VM where traefik is running .
My docker-compose is
version: '3.2'
networks:
netdocker:
external:
name: ntwkr_docker
services:
wstraefik:
image: traefik:v2.6
command: --api.insecure=true --providers.docker
container_name: wstraefik
restart: unless-stopped
networks:
- netdocker
ports:
- 80:80
- 8080:8080
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
labels:
- traefik.enable=true
- traefik.http.services.wstraefik.loadbalancer.server.port=8080
- traefik.http.routers.wstraefik.entrypoints=http
- traefik.http.routers.wstraefik.rule=Host(`ws-traefik.wslan`) && PathPrefix(`/wstraefik`)
When I enter with http://ws-traefik/wstraefik I get the error
404 page not found
On the other hand when I enter with http://ws-traefik:8080/ (without the prefix) the traefik dashboard appears
What is wrong with the service configuration?
Hello @marcos.nobre,
There is a guide in the traefik documentation if you want to expose the dashboard through traefik.
Here, it seems that you have a missmatch between your rule Host(`ws-traefik.wslan`) && PathPrefix(`/wstraefik`)
and the URL you requested http://ws-traefik/wstraefik
. You should have requested ws-traefik.wslan/wstraefik
.
Hope it helps
Here is an example of a working use case :
version: '3.8'
services:
traefik:
image: traefik:v2.6
command:
- --providers.docker
- --api.dashboard=true
- --entrypoints.web.address=:80
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
labels:
traefik.http.routers.dashboard.rule: Host(`traefik.localhost`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))
traefik.http.routers.dashboard.entrypoints: web
traefik.http.routers.dashboard.service: api@internal
Note that this example can be a security risk if you run it without protection in a production environment(e.g. basic auth).
Hi Tommoulard.
First of all, I thank you for your attention.
Regarding my misspelled post, I inform you that the url I am sending is http://ws-traefik.wslan/wstraefik and even then the error "404 page not found" continues to occur.
however when I inform http://ws-traefik.wslan:8080/ , the url is changed to http://ws-traefik.wslan:8080/dashboard/#/ and the dashboard appears.
I'll try your suggestion of docker-compose, but I have the following doubt:
What does the word web that appears in your configuration mean?
...
traefik.http.routers.dashboard.entrypoints: web
...
A traefik verb ? A name ? An alias ?
TIA
MN
Another question is:
In my case what should i exchange for .....( traefik.localhost
) ?
And which url should I call to run the dashboard?
http://ws-traefik.wslan/dasboard
Would it be this ?
As stated in the documentation, doing --entrypoints.web.address=:80
defines an entrypoint called web
that will listen on port 80
. So here, web
is just a custom entrypoint name(e.g. it could have been web-custom
).
This name is used to reference the entrypoint when we need it.
Here for example:
traefik.http.routers.dashboard.entrypoints: web
Here, you can change this to your host of choice, i.e. ws-traefik.wslan
for your use case.
For my example, you will be able to find the dashboard on http://traefik.localhost/dashboard/
.