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?
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.
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