-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker Label Setup Static and Dynamic Config #13
Comments
I have debugged a little more. I created a TOML file: [http.middlewares]
[http.middlewares.rewrite_theme.plugin.theme_changer]
lastModified = true
[[http.middlewares.rewrite_theme.plugin.theme_changer.rewrites]]
regex = "System"
replacement = "ITWORKS" From previous post replaced the line: Removed these lines:
Now I am getting this error output:
|
Hello, I tried something like this and it works perfectly : version: "3.3"
services:
traefik:
image: "traefik:v2.3"
container_name: "traefik"
command:
- "--providers.docker=true"
- "--entrypoints.web.address=:80"
- "--pilot.token=$TOKEN"
- "--experimental.plugins.theme_changer.modulename=github.com/traefik/plugin-rewritebody"
- "--experimental.plugins.theme_changer.version=v0.3.1"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
whoami:
image: "traefik/whoami"
container_name: "simple-service"
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
- "traefik.http.routers.whoami.entrypoints=web"
- "traefik.http.routers.whoami.middlewares=rewrite_theme"
- "traefik.http.middlewares.rewrite_theme.plugin.theme_changer.rewrites[0].regex=Hostname"
- "traefik.http.middlewares.rewrite_theme.plugin.theme_changer.rewrites[0].replacement=Pouet" Do you have any logs informations with your first test ? (by passing --log.level=DEBUG to traefik ) |
Hi youkoulayley, Thanks for the reply. I tried the whoami container also and it works on my system so I am happy that we established that it works via docker labels. However, it will not work with my sonarr container.
Docker container compose file sonarr:
image: ghcr.io/linuxserver/sonarr:preview
container_name: sonarr
restart: unless-stopped
environment:
- PUID=$PUID
- PGID=$PGID
- TZ=$TZ
networks:
- $T2_NETWORK
security_opt:
- no-new-privileges:true
volumes:
- $DOCUMENTS/Sonarr:/config
- $DOCUMENTS/Nzbget/Completed:/downloads
- $MEDIA:/media
labels:
- "traefik.enable=true"
- "traefik.http.routers.sonarr-rtr.entrypoints=web"
- "traefik.http.routers.sonarr-rtr.rule=Host(`sonarr.$BASE_HOST`)"
- "traefik.http.routers.sonarr-rtr.service=sonarr-svc"
- "traefik.http.middlewares.rewrite_sonarr_theme.plugin.theme_changer.rewrites[0].regex=System"
- "traefik.http.middlewares.rewrite_sonarr_theme.plugin.theme_changer.rewrites[0].replacement=WORKS"
- "traefik.http.routers.sonarr-rtr.middlewares=rewrite_sonarr_theme"
- "traefik.http.services.sonarr-svc.loadbalancer.server.port=8989" This is the debug output but I did not see anything useful that I could discern
|
Here's a setup that is working : version: "3.3"
services:
traefik:
image: "traefik:v2.3"
container_name: "traefik"
command:
- "--log.level=DEBUG"
- "--providers.docker=true"
- "--entrypoints.web.address=:80"
- "--pilot.token=$TOKEN"
- "--experimental.plugins.theme_changer.modulename=github.com/traefik/plugin-rewritebody"
- "--experimental.plugins.theme_changer.version=v0.3.1"
ports:
- "80:80"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
sonarr:
image: ghcr.io/linuxserver/sonarr:preview
container_name: sonarr
security_opt:
- no-new-privileges:true
labels:
- "traefik.enable=true"
- "traefik.http.routers.sonarr-rtr.entrypoints=web"
- "traefik.http.routers.sonarr-rtr.rule=Host(`sonar.localhost`)"
- "traefik.http.routers.sonarr-rtr.middlewares=rewritesonarrtheme"
- "traefik.http.routers.sonarr-rtr.service=sonarr-svc"
- "traefik.http.services.sonarr-svc.loadbalancer.server.port=8989"
- "traefik.http.middlewares.rewritesonarrtheme.plugin.theme_changer.rewrites[0].regex=System"
- "traefik.http.middlewares.rewritesonarrtheme.plugin.theme_changer.rewrites[0].replacement=WORKS" I see in your configuration that you specify a custom network : networks:
- $T2_NETWORK Have you tried to add this label on the sonarr container : - "traefik.docker.network=$T2_NETWORK" |
I tried a fresh sonarr container and copied all the settings that you referred too. I am still getting a panic error. I have no idea why and I wish there was more debug information as to why it is happening. This is my traefik settings. I did try adding the traefik:
container_name: traefik
image: traefik:latest
restart: unless-stopped
command:
- --global.checkNewVersion=true
- --api.insecure=true
- --entrypoints.web.address=:80
# (Default: error) DEBUG, INFO, WARN, ERROR, FATAL, PANIC
- --log.level=INFO
# Do not expose containers unless explicitly told so
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --providers.docker.network=$T2_NETWORK
# Traefik Plugins Config
- --pilot.token=$TRAEFIK_TOKEN
- --experimental.plugins.theme_changer.modulename=github.com/traefik/plugin-rewritebody
- --experimental.plugins.theme_changer.version=v0.3.1
networks:
- $T2_NETWORK
ports:
- target: 80
published: 80
protocol: tcp
mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik-rtr.entrypoints=web"
- "traefik.http.routers.traefik-rtr.rule=Host(`traefik.$BASE_HOST`)"
- "traefik.http.routers.traefik-rtr.service=traefik-svc"
- "traefik.http.services.traefik-svc.loadbalancer.server.port=8080" I am experimenting with develop mode for the plugin and added: func (r *rewriteBody) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
wrappedWriter := &responseWriter{
lastModified: r.lastModified,
ResponseWriter: rw,
}
defer func() {
if err := recover(); err != nil {
log.Println("panic occurred:", err)
}
}()
r.next.ServeHTTP(wrappedWriter, req)
bodyBytes := wrappedWriter.buffer.Bytes()
contentEncoding := wrappedWriter.Header().Get("Content-Encoding")
if contentEncoding != "" && contentEncoding != "identity" {
if _, err := rw.Write(bodyBytes); err != nil {
log.Printf("unable to write body: %v", err)
}
return
}
for _, rewrite := range r.rewrites {
bodyBytes = rewrite.regex.ReplaceAll(bodyBytes, rewrite.replacement)
}
if _, err := rw.Write(bodyBytes); err != nil {
log.Printf("unable to write rewrited body: %v", err)
}
} The "additional" error information I got from the log is but not sure what this signifies: |
I see you have an image with the latest tag : Are you sure your docker has downloaded the very latest version of traefik ? |
Tried that and still getting the panic error. |
Could you send me all the logs since the Traefik startup with the panic stack in DEBUG level ? |
See attached log. I removed my token in the log. Is there a way to get a version of the plugin that outputs more information since this is a "panic" event... Just shooting ideas. Thank you so much for your continued help. |
I able to reproduce, so I confirm the issue. |
Hi,
I am trying to get this plugin to work using docker labels. I am not having any success to get it working. For testing, I am trying to replace 'en' to 'es' in the page but cannot get this to work. My goal is to use this to change the theme.
Static Config:
Dynamic Config:
Thank you for any help / direction.
The text was updated successfully, but these errors were encountered: