Hello everyone, I am trying to have a redirect for google's tag manager first party setup, and I have this in my file provider
But I keep getting this error
{"level":"error","providerName":"swarm","container":"marketing-fps-forward-gxyn58z0g12pkfo6jrh0pkb14","error":"field not found, node: servers","time":"2025-01-11T20:50:43Z","caller":"github.com/traefik/traefik/v3/pkg/provider/docker/config.go:46"}
file provider
http:
routers:
fps-forward-router:
rule: "Host(`example.com`) && PathPrefix(`/whatever`)"
priority: 100
tls:
certResolver: letsencrypt
entryPoints:
- websecure
middlewares:
- fps-forward-redirect
service: fps-forward-dummy
services:
# A "dummy" service so that our router can reference *some* service;
fps-forward-dummy:
loadBalancer:
servers:
- url: "http://0.0.0.0"
middlewares:
fps-forward-redirect:
redirectRegex:
# Regex captures the entire path (/whatever...) after the domain
regex: "^https?://example.com(/whatever.*)"
# Replacement sends everything to https://G-xxxx.fps.goog, preserving subpaths & query
replacement: "https://x.fps.goog$1"
permanent: true
This option is listed in the docs, what I am I missing?
Running traefik:v3.2.2
Trying to achieve the steps specified here Set up First-party mode | Google Tag Manager - First-party mode | Google for Developers
Edit: Moved to another solution not using the servers field, but I would still like to know what was happening so I can not make the same mistake in the future
The error comes from providers.swarm, so it’s probably about labels, not about the dynamic config file you shared.
Using a redirect seems very wrong when using Google first party stuff. It will tell the client to go fetch a Google page, which you probably want to avoid with the setup in the first place.
Chatbot answers can be very wrong sometimes.
This is in their guide
- Add an origin or backend that points to
G-12345.fps.goog.
- Override the Host header to be equal to
G-12345.fps.goog. Allow all cookies and query strings to be forwarded.
- Add a path rule for
/metrics/* to route traffic to First-party mode.
- Configure the reserved path to have higher priority than the default rule.
Is there a more appropriate approach than a redirect? Maybe a dummy service that points to this URL? I did try that but it seems that swarm provider has issues with that, or I just misconfigured something
A redirect sends a redirect response to the client. Instead you should use regular Traefik proxy/forward via router and service with the target URL.
EDIT: the experimental version of traefik added the support for loadbalancer.server.url 
It seems that docker swarm does not support the servers option?
I cannot really find anything about it in the docs
network_traefik.1.e6wjsmnf4hzl@manager-1 | {"level":"error","providerName":"swarm","container":"marketing-landing-yisytf7vr38x9nl07pgc5pvbu","error":"field not found, node: servers","time":"2025-01-13T06:56:55Z"}
network_traefik.1.e6wjsmnf4hzl@manager-1 | {"level":"error","providerName":"swarm","container":"marketing-landing-yisytf7vr38x9nl07pgc5pvbu","error":"field not found, node: servers","time":"2025-01-13T06:57:10Z"}
network_traefik.1.e6wjsmnf4hzl@manager-1 | {"level":"error","providerName":"swarm","container":"marketing-landing-yisytf7vr38x9nl07pgc5pvbu","error":"field not found, node: servers","time":"2025-01-13T06:57:25Z"}
network_traefik.1.e6wjsmnf4hzl@manager-1 | {"level":"error","providerName":"swarm","container":"marketing-landing-yisytf7vr38x9nl07pgc5pvbu","error":"field not found, node: servers","time":"2025-01-13T06:57:40Z"}
network_traefik.1.e6wjsmnf4hzl@manager-1 | {"level":"error","providerName":"swarm","container":"marketing-landing-yisytf7vr38x9nl07pgc5pvbu","error":"field not found, node: servers","time":"2025-01-13T06:57:55Z"}
- "traefik.http.routers.fps-forward-router.rule=Host(`$VIRTUAL_HOST`) && PathPrefix(`/matrix`)"
- "traefik.http.routers.fps-forward-router.priority=100"
- "traefik.http.routers.fps-forward-router.entryPoints=websecure"
- "traefik.http.routers.fps-forward-router.tls.certresolver=letsencrypt"
- "traefik.http.routers.fps-forward-router.service=fps-forward-service"
- "traefik.http.routers.fps-forward-router.middlewares=fps-forward-header"
- "traefik.http.middlewares.fps-forward-header.headers.customrequestheaders.Host=$GOOGLE_TAG_ID.fps.goog"
- "traefik.http.services.fps-forward-service.loadBalancer.servers.0.address=https://$GOOGLE_TAG_ID.fps.goog"
- "traefik.http.services.fps-forward-service.loadBalancer.servers.0.tls=true"
- "traefik.http.services.fps-forward-service.loadBalancer.passHostHeader=true"
The current doc (at this point v3.3) does not enable url on labels, only in file:
http:
services:
my-service:
loadBalancer:
servers:
- url: "http://private-ip-server-1/"
Also experimental doc does not include it in labels.
Also docker reference experimental does not include it:
- "traefik.http.services.service02.loadbalancer.server.port=foobar"
- "traefik.http.services.service02.loadbalancer.server.preservepath=true"
- "traefik.http.services.service02.loadbalancer.server.scheme=foobar"
- "traefik.http.services.service02.loadbalancer.server.url=foobar"
- "traefik.http.services.service02.loadbalancer.server.weight=42"
But in master branch providers.docker there is such a label (code):
"traefik.http.services.Service1.LoadBalancer.server.url": "http://1.2.3.4:5678"
And the issue has been closed now. Latest release v3.3.1 is older than the pull request, so we hopefully get it in the next release 