I get the follwing error
error reading configuration file: /opt/traefik/routes/static.toml - open /opt/traefik/routes/static.toml: no such file or directory
However I did have the file in /opt/otherpath/static.toml with a symlink to /opt/traefik/routes/static.toml. I was confused of this message since my traefik.toml showed
[providers]
providersThrottleDuration = "2s"
[providers.file]
directory = "/opt/traefik/routes"
watch = true
So I decided to change the directory to /opt/traefik.... but after the reload the same error keeps showing.. How is it possible if my new directory in providers is /opt/traefik.
Share your Traefik static and dynamic config, and docker-compose.yml if used.
Use 3 backticks in front and after the code to format it, or select the code and press the </> button.
I over simplified my code to understand the problems I get..
static.toml
[serversTransport]
insecureSkipVerify = true
[http.routers]
[http.routers.dashboard]
entryPoints = ["http"]
service = "api@internal"
traefik.toml
[log]
level = "INFO"
filePath = "/var/log/traefik/traefik.log"
[providers]
providersThrottleDuration = "2s"
[providers.file]
directory = "/opt/traefik/"
watch = true
[api]
insecure = true
dashboard = true
[entryPoints]
[entryPoints.web]
address = ":10080"
[entryPoints.dashboard]
address = ":8081"
And the error I get is
time="2023-07-03T17:44:00Z" level=error msg="Cannot start the provider *file.Provider: unable to load content configuration from subdirectory &{/opt/traefik/ routes %!s(fs.FileMode=21474836
static.toml: error reading configuration file: /opt/traefik/routes/static.toml - open /opt/traefik/routes/static.toml: no such file or directory"
- Why it says subdirectory
/opt/traefik/ routes %!s(.... when my file now says directory = "/opt/traefik/" I somehow removed the routes directory....
- Also when I access localhost:8080 I can see the dashboard (which is great finally I get something)...But my dashboard shows
DASHBOARD :8081
TRAEFIK :8080
WEB :10080
I actually thought that by choosing 8081 in traefik.toml I will be able to see the dashboard considering localhost:8081....but no...the dashboard comes with port 8080...then what exactly am I defining with port 8081 (referred to as TRAEFIK). Is this normal behavior?Or it should be port 8081 as I thought initially
Your traefik.toml is the static config, global serversTransport should be in there, http goes into dynamic config loaded via provider.
When you use insecure, Traefik will automatically create Dashboard on port 8080.
See simple Traefik example for dashboard on websecure entrypoint.
I would think that you created a symlink in the filesystem and the target file are not there anymore.
Thanks you were right, seems almost perfect now, a last error is popping up: error while parsing rule : 1:1: expected operand, found 'EOF' entryPointName=web routerName=dashboard@file .. There is no solution online about it.... my new files read
[log]
level = "INFO"
filePath = "/var/log/traefik/traefik.log"
[providers]
providersThrottleDuration = "2s"
[providers.file]
directory = "/opt/traefik/"
watch = true
[api]
insecure = true
dashboard = true
[entryPoints]
[entryPoints.web]
address = ":10080"
[entryPoints.dashboard]
address = ":8081"
[serversTransport]
insecureSkipVerify = true
and
[http.routers]
[http.routers.dashboard]
entryPoints = ["web"]
service = "api@internal"
I wonder if it is fixable or it is because I'm using a simple template
To solve this issue consider the following (mainly your need to add rule):
[http.routers.traefik]
entryPoints = ["web"]
rule = "Host(`traefik.localhost`) && PathPrefix(`/api`, `/dashboard`)"
service = "api@internal"
or with secure port:
[http.routers.traefik]
entryPoints = ["websecure"]
rule = "Host(`traefik.localhost`) && PathPrefix(`/api`, `/dashboard`)"
service = "api@internal"
[http.routers.traefik.tls]
or if you prefer don't pay attention to this error as things work ok without fixing it