sablierapp / sablier

Start your containers on demand, shut them down automatically when there's no activity. Docker, Docker Swarm Mode and Kubernetes compatible.
https://sablierapp.dev/
GNU Affero General Public License v3.0
1.44k stars 47 forks source link

Use of custom pages - how to? #16

Closed SAOPP closed 2 years ago

SAOPP commented 2 years ago

Hi!

Guys, what the command I need to add in plugin container for use custom pages?

I don't quite understand, based on the description there is only a block, can I use labels in the plugin container, if so which ones?

acouvreur commented 2 years ago

I used the sources from examples/docker_swarm and tweaked it just to add a custom loading page :

version: "3.9"

services:
  traefik:
    image: traefik
    command:
      - --api=true
      - --api.insecure=true
      - --pilot.token=$TRAEFIK_PILOT_TOKEN
      - --experimental.plugins.traefik-ondemand-plugin.moduleName=github.com/acouvreur/traefik-ondemand-plugin
-     - --experimental.plugins.traefik-ondemand-plugin.version=v1.0.1 # Custom loading pages are in 1.1.0
+     - --experimental.plugins.traefik-ondemand-plugin.version=v1.1.0
      - --providers.docker=true
      - --providers.docker.swarmmode=true
      - --providers.file.filename=/etc/traefik/dynamic-config.yml
      - --entrypoints.http.address=:80
      - --entrypoints.https.address=:443
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock'
+     - './mycustompages:/etc/traefik/plugins/traefik-ondemand-plugin/custompages'

  ondemand:
    image: ghcr.io/acouvreur/traefik-ondemand-service:1
    command:
      - --swarmMode=true
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock'
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.middlewares.ondemand.plugin.traefik-ondemand-plugin.name=DOCKER_SWARM_nginx
        - traefik.http.middlewares.ondemand.plugin.traefik-ondemand-plugin.serviceUrl=http://ondemand:10000
        - traefik.http.middlewares.ondemand.plugin.traefik-ondemand-plugin.timeout=1m
+       - traefik.http.middlewares.ondemand.plugin.traefik-ondemand-plugin.loadingpage=/etc/traefik/plugins/traefik-ondemand-plugin/custompages/loading.html
+       - traefik.http.middlewares.ondemand.plugin.traefik-ondemand-plugin.errorpage=/etc/traefik/plugins/traefik-ondemand-plugin/custompages/error.html
        - traefik.http.services.ondemand.loadbalancer.server.port=10000

  nginx:
    image: nginx
    deploy:
      replicas: 0
      labels:
        - traefik.enable=true
        # If you do not use the swarm load balancer, traefik will evict the service from its pool
        # as soon as the service is 0/0. If you do not set that, fallback to dynamic-config.yml file usage.
        - traefik.docker.lbswarm=true
        - traefik.http.routers.nginx.middlewares=ondemand@docker
        - traefik.http.routers.nginx.rule=PathPrefix(`/nginx`)
        - traefik.http.services.nginx.loadbalancer.server.port=80

You need to add a volume (or swarm config) with your custom loading pages.

Your HTML page must include the following :

<meta http-equiv="refresh" content="5" />

Because otherwise it will not automatically reload. You can custom the refresh rate.

You have access to the following struct in loading :

type LoadingData struct {
    Name    string
    Timeout string
}

And in error :

type ErrorData struct {
    Name  string
    Error string
}

Pages are Go Templates, so feel free to do what you want with it ! Example in error.html :

<h2 class="headline" id="headline">Error loading {{ .Name }}.</h2>
SAOPP commented 2 years ago

Yeah, okay, I see your volume with custom pages, and see the labels, awesome. But, I was think some custome pages are available in the plugin or in this repos - no? I mean, I need to get them from somewhere or write it by my self? :) I'm saw a screenshoots in repo, and thinked it's something like custom pages in plugin.. :D

acouvreur commented 2 years ago

Default pages are available here: https://github.com/acouvreur/traefik-ondemand-plugin/tree/main/pkg/pages

Loading page: https://github.com/acouvreur/traefik-ondemand-plugin/blob/main/pkg/pages/loading.html Error page: https://github.com/acouvreur/traefik-ondemand-plugin/blob/main/pkg/pages/error.html

SAOPP commented 2 years ago

ah, okay, sorry, I was wrong, I found it ova here: https://github.com/acouvreur/traefik-ondemand-plugin/tree/main/pkg/pages :D sorry, thanks ;) I will try.

SAOPP commented 2 years ago

What I do wrong?

Some from traefik container:

      # On demand plugin
      - --experimental.plugins.traefik-ondemand-plugin.moduleName=github.com/acouvreur/traefik-ondemand-plugin
      - --experimental.plugins.traefik-ondemand-plugin.version=v1.1.0

      # Ondemand plugin custom pages
      - /home/docker_storage/traefik-ondemand:/etc/traefik/plugins/traefik-ondemand-plugin/custompages

      /home/docker_storage/traefik-ondemand$ 
      -rw-r--r--  1 root root 3272 Dec 14 15:49 error.html
      -rw-r--r--  1 root root 4645 Dec 14 15:49 loading.html

ondemand container:

  traefik-ondemand:
    image: ghcr.io/acouvreur/traefik-ondemand-service:1
    container_name: traefik-ondemand
    command: 
      - --swarmMode=false
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - 10000:10000
    labels:
      - traefik.enable=true
      - traefik.http.middlewares.remmina-ondemand.plugin.traefik-ondemand-plugin.name=remmina
      - traefik.http.middlewares.remmina-ondemand.plugin.traefik-ondemand-plugin.serviceUrl=http://192.168.1.4:10000
      - traefik.http.middlewares.remmina-ondemand.plugin.traefik-ondemand-plugin.timeout=5m
      - traefik.http.middlewares.remmina-ondemand.plugin.traefik-ondemand-plugin.loadingpage=/etc/traefik/plugins/traefik-ondemand-plugin/custompages/loading.html
      - traefik.http.middlewares.remmina-ondemand.plugin.traefik-ondemand-plugin.errorpages=/etc/traefik/plugins/traefik-ondemand-plugin/custompages/error.html
      - traefik.http.services.traefik-ondemand.loadbalancer.server.port=10000

My service:

  remmina:
    image: lscr.io/linuxserver/remmina:latest
    container_name: remmina
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Kiev
    volumes:
      - /home/docker_storage/remmina:/config
    ports:
      - 3000:3000
    restart: unless-stopped
    labels:
      - traefik.enable=true
      - traefik.http.services.remmina.loadbalancer.server.port=3000
      - traefik.http.routers.remmina.rule=Host(`remmina.${DOMAIN}`)
      - traefik.http.routers.remmina.entrypoints=websecure
      - traefik.http.routers.remmina.tls=true
      - traefik.http.routers.remmina.tls.certresolver=myresolver
      - traefik.http.routers.remmina.middlewares=remmina-ondemand@docker

After change plugin version and add volume with custom pages, and path to this pages in ondemand containr, I get 404 default page if container is down :| What I do wrong?

acouvreur commented 2 years ago

Your Traefik configuration may have so issues, can you print the Ondemand and Traefik logs ?

SAOPP commented 2 years ago

But with previous version all works fine, and in traefik dashboard any errors not found also. Ondemand turn off container, if I run it, but no started it.

SAOPP commented 2 years ago

I seem to figure it out, I need to keep my host settings in a file, not in the container labels. I'll try...

SAOPP commented 2 years ago

No, something wrong, if I use dynamic config, with 1.1.0 version and custom pages, container no run.

acouvreur commented 2 years ago

Can you give me the whole configuration ? So I can try it out ?

If you can give me some logs from Traefik, and Ondemand service it'll be helpful, thanks!

SAOPP commented 2 years ago

Okay, I driving right now, but see this from my phone:

template: loading:225:57: executing "loading" at <.Timeout>: can't evaluate field Timeout in type struct { Name string; Error string }template: loading:225:57: executing "loading" at <.Timeout>: can't evaluate field Timeout in type struct { Name string; Error string }

acouvreur commented 2 years ago

Oh, you may have the wrong template inside your error.html file ! We may need to have a better error handling I guess :thinking:

SAOPP commented 2 years ago

Oh, container is started

SAOPP commented 2 years ago

Okay I downloading templates again...

acouvreur commented 2 years ago

Feel free to provide feedback!

SAOPP commented 2 years ago

Strange, redownloaded the templates, and the same result as above. :/

SAOPP commented 2 years ago

I will try to set proper permissions in folder...

SAOPP commented 2 years ago

Ondemand logs is fine as I see:

Server listening on port 10000, swarmMode: false, kubernetesMode: false
time="2021-12-14T15:11:09Z" level=info msg="Scaling down remmina to 0"
time="2021-12-14T15:16:33Z" level=info msg="Scaling up remmina to 1"
time="2021-12-14T15:30:13Z" level=info msg="Scaling down remmina to 0"
time="2021-12-14T15:30:40Z" level=info msg="Scaling up remmina to 1"
time="2021-12-14T15:35:50Z" level=info msg="Scaling down remmina to 0"
time="2021-12-14T15:41:11Z" level=info msg="Scaling up remmina to 1"
time="2021-12-14T15:46:32Z" level=info msg="Scaling down remmina to 0"
time="2021-12-14T16:10:46Z" level=info msg="Scaling up remmina to 1"
time="2021-12-14T16:15:52Z" level=info msg="Scaling down remmina to 0"
time="2021-12-14T16:20:36Z" level=info msg="Scaling up remmina to 1"
time="2021-12-14T16:33:26Z" level=info msg="Scaling down remmina to 0"
time="2021-12-14T17:30:33Z" level=info msg="Scaling up remmina to 1"
time="2021-12-14T17:40:05Z" level=info msg="Scaling down remmina to 0"
time="2021-12-14T18:03:15Z" level=info msg="Scaling up remmina to 1"
time="2021-12-14T18:11:42Z" level=info msg="Scaling down remmina to 0"
time="2021-12-14T18:17:43Z" level=info msg="Scaling up remmina to 1"
time="2021-12-14T18:22:59Z" level=info msg="Scaling down remmina to 0"
time="2021-12-14T19:45:16Z" level=info msg="Scaling up remmina to 1"

One second, I will try to catch some ondemand outputs from traefik...

SAOPP commented 2 years ago

It's from remmina router:

image

SAOPP commented 2 years ago

My Traefik container:

  traefik:
    image: traefik:latest
    container_name: traefik
    command:
      - --log.level=DEBUG
      - --api.insecure=true
      - --providers.docker=true
      - --providers.docker.exposedbydefault=false
      # File dymanic configurations for remote services
      - --providers.file.directory=/dynamic_conf
      - --providers.file.watch=true
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --entrypoints.web.http.redirections.entryPoint.to=websecure
      - --entrypoints.traefik.address=:81
      #- --certificatesresolvers.le.acme.tlschallenge=true
      - --certificatesresolvers.myresolver.acme.httpchallenge=true
      - --certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web
      - --certificatesresolvers.myresolver.acme.email=${EMAIL}
      - --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json
      - --pilot.token=${TRAEFIK_PILOT_TOKEN}
      # On demand plugin
      - --experimental.plugins.traefik-ondemand-plugin.moduleName=github.com/acouvreur/traefik-ondemand-plugin
      - --experimental.plugins.traefik-ondemand-plugin.version=v1.1.0
    environment:
      - TZ=Europe/Kiev
    ports:
      - 80:80
      - 8246:81
      - 443:443
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - traefik-le:/letsencrypt
      # Remote services dynamic configuration folder
      - /home/docker_storage/traefik:/dynamic_conf
      # Ondemand plugin custom pages
      - /home/docker_storage/traefik-ondemand:/etc/traefik/plugins/traefik-ondemand-plugin/custompages
    #network_mode: host
    restart: unless-stopped
    extra_hosts:
      - host.docker.internal:172.24.0.1
    networks:
      - web
    labels:
      - diun.enable=true
      # Redirect HTTP traffic to HTTPS
      - traefik.http.routers.redirs.rule=hostregexp(`{host:.+}`)
      - traefik.http.routers.redirs.entrypoints=web
      - traefik.http.routers.redirs.middlewares=redirect-to-https
      - traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
      # Dashboard
      - traefik.enable=true
      - traefik.http.routers.dashboard.rule=Host(`proxy.${DOMAIN}`)
      - traefik.http.routers.dashboard.service=api@internal
      - traefik.http.services.dashboard.loadbalancer.server.port=81
      - traefik.http.routers.dashboard.entrypoints=websecure
      - traefik.http.routers.dashboard.tls=true
      - traefik.http.routers.dashboard.tls.certresolver=myresolver
      - traefik.http.routers.dashboard.middlewares=authelia@docker
Ondemand container:
  traefik-ondemand:
    image: ghcr.io/acouvreur/traefik-ondemand-service:1
    container_name: traefik-ondemand
    command: 
      - --swarmMode=false
    networks:
      - web
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - 10000:10000
    labels:
      - traefik.enable=true
      - traefik.http.middlewares.remmina-ondemand.plugin.traefik-ondemand-plugin.name=remmina
      - traefik.http.middlewares.remmina-ondemand.plugin.traefik-ondemand-plugin.serviceUrl=http://192.168.1.4:10000
      - traefik.http.middlewares.remmina-ondemand.plugin.traefik-ondemand-plugin.timeout=5m
      - traefik.http.middlewares.remmina-ondemand.plugin.traefik-ondemand-plugin.loadingpage=/etc/traefik/plugins/traefik-ondemand-plugin/custompages/loading.html
      - traefik.http.middlewares.remmina-ondemand.plugin.traefik-ondemand-plugin.errorpages=/etc/traefik/plugins/traefik-ondemand-plugin/custompages/error.html
      - traefik.http.services.traefik-ondemand.loadbalancer.server.port=10000
SAOPP commented 2 years ago

"traefik-ondemand-system":{"service":"traefik-ondemand","rule":"Host(traefik-ondemand-system)"},

\"remmina-ondemand\":{\"plugin\":{\"traefik-ondemand-plugin\":{\"errorpages\":\"/etc/traefik/plugins/traefik-ondemand-plugin/custompages/error.html\",\"loadingpage\":\"/etc/traefik/plugins/traefik-ondemand-plugin/custompages/loading.html\",\"name\":\"remmina\",\"serviceUrl\":\"http://192.168.1.4:10000\",\"timeout\":\"5m\"}}}}},\"tcp\":{},\"udp\":{}}" providerName=docker

Here is some from traefik logs... I don't know, what is going on, maybe the power of my remote server affects something, it is really old for today, I just ran out of thoughts, what is wrong... :|

SAOPP commented 2 years ago

And the last one thing, this is right now after open my remmina url:

template: loading:225:57: executing "loading" at <.Timeout>: can't evaluate field Timeout in type struct { Name string; Error string }template: loading:225:57: executing "loading" at <.Timeout>: can't evaluate field Timeout in type struct { Name string; Error string }

SAOPP commented 2 years ago

Here is Traefik log after I'm open remmina.mydomain.com - I changed some sensitive info like ip, domain and etc:

2021/12/14 22:18:32 Status: error
2021/12/14 22:18:32 Sending request: http://192.168.1.4:10000?name=remmina&timeout=5m0s
2021/12/14 22:18:30 Sending request: http://192.168.1.4:10000?name=remmina&timeout=5m0s
time="2021-12-14T22:18:33+02:00" level=debug msg="Provider event received {Status:start ID:21a61df1d1ea33c3715e7d2d5322360661809242eba4ece9573447dc2156cae1 From:lscr.io/linuxserver/remmina:latest Type:container Action:start Actor:{ID:21a61df1d1ea33c3715e7d2d5322360661809242eba4ece9573447dc2156cae1 Attributes:map[build_version:Linuxserver.io version:- 1.2.0-rcgit.29dfsg-1ubuntu1-ls80 Build-date:- 2021-12-13T14:52:05+01:00 com.centurylinklabs.watchtower.scope:watchtower-system com.docker.compose.config-hash:1673c817dc9f256dca7b5558c99a5f425c67954e0871e67b1db436ef97893ef6 com.docker.compose.container-number:1 com.docker.compose.oneoff:False com.docker.compose.project:system com.docker.compose.project.config_files:/data/compose/105/docker-compose.yml com.docker.compose.project.environment_file:stack.env com.docker.compose.project.working_dir:/data/compose/105 com.docker.compose.service:remmina com.docker.compose.version:1.27.4 diun.enable:true image:lscr.io/linuxserver/remmina:latest maintainer:thelamer name:remmina org.opencontainers.image.authors:linuxserver.io org.opencontainers.image.created:2021-12-13T14:52:05+01:00 org.opencontainers.image.description:Remmina is a remote desktop client written in GTK, aiming to be useful for system administrators and travellers, who need to work with lots of remote computers in front of either large or tiny screens. Remmina supports multiple network protocols, in an integrated and consistent user interface. Currently RDP, VNC, SPICE, NX, XDMCP, SSH and EXEC are supported. org.opencontainers.image.documentation:https://docs.linuxserver.io/images/docker-remmina org.opencontainers.image.licenses:GPL-3.0-only org.opencontainers.image.ref.name:e1ed13b1bf7f55d9e76d0c41c9f63e27bc6a3c20 org.opencontainers.image.revision:e1ed13b1bf7f55d9e76d0c41c9f63e27bc6a3c20 org.opencontainers.image.source:https://github.com/linuxserver/docker-remmina org.opencontainers.image.title:Remmina org.opencontainers.image.url:https://github.com/linuxserver/docker-remmina/packages org.opencontainers.image.vendor:linuxserver.io org.opencontainers.image.version:1.2.0-rcgit.29dfsg-1ubuntu1-ls80]} Scope:local Time:1639513113 TimeNano:1639513113849558786}" providerName=docker
2021/12/14 22:18:33 Status: started
time="2021-12-14T22:18:33+02:00" level=debug msg="vulcand/oxy/roundrobin/rr: begin ServeHttp on request" Request="{"Method":"GET","URL":{"Scheme":"","Opaque":"","User":null,"Host":"","Path":"/favicon.ico","RawPath":"","ForceQuery":false,"RawQuery":"","Fragment":"","RawFragment":""},"Proto":"HTTP/2.0","ProtoMajor":2,"ProtoMinor":0,"Header":{"Accept":["image/avif,image/webp,image/apng,image/svg+xml,image/,/;q=0.8"],"Accept-Encoding":["gzip, deflate, br"],"Accept-Language":["ru,en;q=0.9"],"Cookie":["authelia_session=G97LG7fB7grCN8EJ3MsjAnXQU6j0Dm"],"Referer":["https://remmina.mydomain.com/"],"Sec-Ch-Ua":["\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"96\", \"Google Chrome\";v=\"96\""],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Ch-Ua-Platform":["\"Linux\""],"Sec-Fetch-Dest":["image"],"Sec-Fetch-Mode":["no-cors"],"Sec-Fetch-Site":["same-origin"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"],"X-Forwarded-Host":["remmina.mydomain.com"],"X-Forwarded-Port":["443"],"X-Forwarded-Proto":["https"],"X-Forwarded-Server":["traefik"],"X-Real-Ip":["30.01.24.54"]},"ContentLength":0,"TransferEncoding":null,"Host":"remmina.mydomain.com","Form":null,"PostForm":null,"MultipartForm":null,"Trailer":null,"RemoteAddr":"30.01.24.54:44668","RequestURI":"/favicon.ico","TLS":null}"
time="2021-12-14T22:18:33+02:00" level=debug msg="vulcand/oxy/roundrobin/rr: Forwarding this request to URL" Request="{"Method":"GET","URL":{"Scheme":"","Opaque":"","User":null,"Host":"","Path":"/favicon.ico","RawPath":"","ForceQuery":false,"RawQuery":"","Fragment":"","RawFragment":""},"Proto":"HTTP/2.0","ProtoMajor":2,"ProtoMinor":0,"Header":{"Accept":["image/avif,image/webp,image/apng,image/svg+xml,image/,/;q=0.8"],"Accept-Encoding":["gzip, deflate, br"],"Accept-Language":["ru,en;q=0.9"],"Cookie":["authelia_session=G97LG7fB7grCN8EJ3MsjAnXQU6j0Dm"],"Referer":["https://remmina.mydomain.com/"],"Sec-Ch-Ua":["\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"96\", \"Google Chrome\";v=\"96\""],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Ch-Ua-Platform":["\"Linux\""],"Sec-Fetch-Dest":["image"],"Sec-Fetch-Mode":["no-cors"],"Sec-Fetch-Site":["same-origin"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"],"X-Forwarded-Host":["remmina.mydomain.com"],"X-Forwarded-Port":["443"],"X-Forwarded-Proto":["https"],"X-Forwarded-Server":["traefik"],"X-Real-Ip":["30.01.24.54"]},"ContentLength":0,"TransferEncoding":null,"Host":"remmina.mydomain.com","Form":null,"PostForm":null,"MultipartForm":null,"Trailer":null,"RemoteAddr":"30.01.24.54:44668","RequestURI":"/favicon.ico","TLS":null}" ForwardURL="http://192.168.1.4:3000"
time="2021-12-14T22:18:33+02:00" level=debug msg="vulcand/oxy/roundrobin/rr: completed ServeHttp on request" Request="{"Method":"GET","URL":{"Scheme":"","Opaque":"","User":null,"Host":"","Path":"/favicon.ico","RawPath":"","ForceQuery":false,"RawQuery":"","Fragment":"","RawFragment":""},"Proto":"HTTP/2.0","ProtoMajor":2,"ProtoMinor":0,"Header":{"Accept":["image/avif,image/webp,image/apng,image/svg+xml,image/,/*;q=0.8"],"Accept-Encoding":["gzip, deflate, br"],"Accept-Language":["ru,en;q=0.9"],"Cookie":["authelia_session=G97LG7fB7grCN8EJ3MsjAnXQU6j0Dm"],"Referer":["https://remmina.mydomain.com/"],"Sec-Ch-Ua":["\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"96\", \"Google Chrome\";v=\"96\""],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Ch-Ua-Platform":["\"Linux\""],"Sec-Fetch-Dest":["image"],"Sec-Fetch-Mode":["no-cors"],"Sec-Fetch-Site":["same-origin"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"],"X-Forwarded-Host":["remmina.mydomain.com"],"X-Forwarded-Port":["443"],"X-Forwarded-Proto":["https"],"X-Forwarded-Server":["traefik"],"X-Real-Ip":["30.01.24.54"]},"ContentLength":0,"TransferEncoding":null,"Host":"remmina.mydomain.com","Form":null,"PostForm":null,"MultipartForm":null,"Trailer":null,"RemoteAddr":"30.01.24.54:44668","RequestURI":"/favicon.ico","TLS":null}"
time="2021-12-14T22:18:33+02:00" level=debug msg="'502 Bad Gateway' caused by: read tcp 172.24.0.14:37422->192.168.1.4:3000: read: connection reset by peer"
SAOPP commented 2 years ago

Maybe need add some wait evn before container is started up? I see 502 Bad Gateway error before 3000 port of remmina started up, it's not available at request moment.

SAOPP commented 2 years ago
+       - traefik.http.middlewares.ondemand.plugin.traefik-ondemand-plugin.loadingpage=/etc/traefik/plugins/traefik-ondemand-plugin/custompages/loading.html
+       - traefik.http.middlewares.ondemand.plugin.traefik-ondemand-plugin.errorpages=/etc/traefik/plugins/traefik-ondemand-plugin/custompages/error.html

It's a really correct paths?

.loadingpage= .errorpages=

acouvreur commented 2 years ago

I'd advise you to use the internal docker DNS (service discovery) to contact your services.

You are using a network called web, ensure that remina is also using the same network.

With this you can change traefik-ondemand labels:

-       - traefik.http.middlewares.remmina-ondemand.plugin.traefik-ondemand-plugin.serviceUrl=http://192.168.1.4:10000
+      - traefik.http.middlewares.remmina-ondemand.plugin.traefik-ondemand-plugin.serviceUrl=http://traefik-ondemand:10000

The other issue you might run into is container readiness. Your container may be started, but they may not be able to receive requests. To deal with this, we use docker healthchecks, if your container provides one, we will wait for the container to be healthy.

The 502 Bad gateway sometimes mean that Traefik is not able to reach your container, or your service is not able to receive requests.

I see that your are also using 192.168.1.4:3000 for your remina container. You should also use the internal dns.

acouvreur commented 2 years ago

Ok, there was an error introduced in 1.1.0, I'll fix it

SAOPP commented 2 years ago

Sure, all these container in one docker network, and yes I tried internal ondemand dns in service url string also, 'bout remmina healthcheck, it's not present in container, I can try to add sometging like curl port checker... and againg, this machine is old, maybe some delays is my current trouble :)

And one more thing, this remmina is a very heavy container for this my remote host, therefore, there is an option to test ondemand on some light container that doesn't need a gui ane etc.

Right now I will check internal dns again...

acouvreur commented 2 years ago
+       - traefik.http.middlewares.ondemand.plugin.traefik-ondemand-plugin.loadingpage=/etc/traefik/plugins/traefik-ondemand-plugin/custompages/loading.html
+       - traefik.http.middlewares.ondemand.plugin.traefik-ondemand-plugin.errorpages=/etc/traefik/plugins/traefik-ondemand-plugin/custompages/error.html

It's a really correct paths?

.loadingpage= .errorpages=

You are right, I did a typo there ! There is no trailing s !

acouvreur commented 2 years ago

Which explains why you got the default error page bug that I resolved in #17

SAOPP commented 2 years ago

I added healthcheck to container and will try to test it...

SAOPP commented 2 years ago

You are right, I did a typo there ! There is no trailing s ! So correct is .loadingpage= and .errorpage= ?

acouvreur commented 2 years ago

You are right, I did a typo there ! There is no trailing s ! So correct is .loadingpage= and .errorpage= ?

Yes! :smile:

SAOPP commented 2 years ago

image

:smiley:

SAOPP commented 2 years ago

But, tell me please one, it's a default page or my custom? :smile:

acouvreur commented 2 years ago

For this you must change your file haha, I suppose you can edit them without reloading the container and so as it will load the file each time. Which maybe isn't that great tbh

SAOPP commented 2 years ago

And I got one more question... 'bout providers for container witch working via ondemand, I need to put all host settings in file or can I still use labels only format? I mean, right now remmina container doesn't have any traefik labels, I provided all host info via dynamic config for traefik.

For this you must change your file haha, I suppose you can edit them without reloading the container and so as it will load the file each time. Which maybe isn't that great tbh

'bout this, u mean, u was talking me above about some of string in html - it's what about u talking right now?

acouvreur commented 2 years ago

And I got one more question... 'bout providers for container witch working via ondemand, I need to put all host settings in file or can I still use labels only format? I mean, right now remmina container doesn't have any traefik labels, I provided all host info via dynamic config for traefik.

Unfortunately this is a Traefik dynamic routing limitation for docker classic. You cannot use labels because as soon as the container is stopped, the labels are not treated by Traefik. The route doesn't exist anymore, so we use dynamic-config.yml file instead.

This is possible with docker swarm mode, but for this you need to do the following:

If you do not use the swarm load balancer, traefik will evict the service from its pool as soon as the service is 0/0. If you do not set that, fallback to dynamic-config.yml file usage. In docker deploy labels. -docker.lbswarm=true

For this you must change your file haha, I suppose you can edit them without reloading the container and so as it will load the file each time. Which maybe isn't that great tbh

'bout this, u mean, u was talking me above about some of string in html - it's what about u talking right now?

Yes, I'm talking about the HTML files you mapped via your volumes. You can custom them.

SAOPP commented 2 years ago

Unfortunately this is a Traefik dynamic routing limitation for docker classic. You cannot use labels because as soon as the container is stopped, the labels are not treated by Traefik.

Yes, It what I was saw and why I ask u :D

Yes, I'm talking about the HTML files you mapped via your volumes. You can custom them.

I had placed default templates into volume for ondemand, something I can't find some custom template to try it...

acouvreur commented 2 years ago

Unfortunately this is a Traefik dynamic routing limitation for docker classic. You cannot use labels because as soon as the container is stopped, the labels are not treated by Traefik.

Yes, It what I was saw and why I ask u :D

Oh, I get it. You can use both. You have to use file and docker provider in your static config. That's all.