# Guacamole behind Traefik v3.3.4 / Pb with PathPrefix

**URL:** https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743
**Category:** Traefik v3 (latest)
**Tags:** docker, middleware
**Created:** [March 4, 2025, 5:58pm UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743 "2025-03-04T17:58:10Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![ThierryIT](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thierryit/32/8446_2.png) [@ThierryIT](https://community.traefik.io/u/ThierryIT)
#### Post date: [March 4, 2025, 5:58pm UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/1 "2025-03-04T17:58:10Z")

</div>

Hello,

My Guacamole is working well behinf my traefik. Except I have to add `'/guacamole'` at the end of his URL like: `https://guacamole.domain.tls/guacamole`

I had during this day fight with labels, none are working.

I have add the middleware in my dynamic file

```auto
add-prefix-guacamole:
      addPrefix:
        prefix: "/guacamole"

```

Labels is my Guacamole compose file:

```auto
- "traefik.enable=true"
      - "traefik.http.routers.guacamole-rtr.entrypoints=https-external"
      - "traefik.http.routers.guacamole-rtr.tls=true"
      - "traefik.http.routers.guacamole-rtr.tls.certresolver=dns-cloudflare"
      - "traefik.http.routers.guacamole-rtr.service=guacamole"
      - "traefik.http.routers.guacamole-rtr.rule=Host(`guacamole.domain.org`)" # && PathPrefix(`/guacamole/`)"
      - "traefik.http.routers.guacamole-rtr.rule=PathPrefix(`/guacamole`)"
      - "traefik.http.middlewares.add-prefix-guacamole=/guacamole"
      #- "traefik.http.routers.guacamole-rtr.middlewares=authentik@file"
      - "traefik.http.services.guacamole.loadBalancer.server.port=8080"
      - "traefik.docker.network=my-net"

```

Thx

---

<div class="post-metadata">

### Author: ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)
#### Post date: [March 4, 2025, 8:13pm UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/2 "2025-03-04T20:13:41Z")

</div>

Create an additional router with `rule=Host(…) && Path(`/`)` and send a redirect to `/guacamole`. So the initial request to domain will automatically go to the required path.

You can’t simply add a prefix to every request, as the page will load dependencies like scripts and images, which will not work anymore.

By the way, this does not work, it will probably just overwrite the first router:

> [@ThierryIT](#):
>
> ```auto
> - "traefik.http.routers.guacamole-rtr.rule=Host(`guacamole.domain.org`)" # && PathPrefix(`/guacamole/`)"
> - "traefik.http.routers.guacamole-rtr.rule=PathPrefix(`/guacamole`)"
> 
> ```

---

<div class="post-metadata">

### Author: ![ThierryIT](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thierryit/32/8446_2.png) [@ThierryIT](https://community.traefik.io/u/ThierryIT)
#### Post date: [March 5, 2025, 6:45am UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/3 "2025-03-05T06:45:18Z")

</div>

```auto
labels:
      - "traefik.enable=true"

  # Router for Root URL Redirection
      - "traefik.http.routers.redirect-root-router.rule=Path(`/`)"
      - "traefik.http.routers.guacamole-router.rule=Host(`guacamole.domain.org`)"
      - "traefik.http.routers.redirect-root-router.entrypoints=https-external"
      - "traefik.http.routers.redirect-root-router.middlewares=redirect-root-to-guacamole"
      - "traefik.http.routers.redirect-root-router.tls=true"
      - "traefik.http.routers.redirect-root-router.tls.certresolver=dns-cloudflare"

  # Middleware to Redirect from / to /guacamole/
      - "traefik.http.middlewares.redirect-root-to-guacamole.redirectregex.regex=^/$"
      - "traefik.http.middlewares.redirect-root-to-guacamole.redirectregex.replacement=/guacamole/"
      - "traefik.http.middlewares.redirect-root-to-guacamole.redirectregex.permanent=true"

  # Main Guacamole Router
      - "traefik.http.routers.guacamole-router.rule=PathPrefix(`/guacamole`)"
      - "traefik.http.routers.guacamole-router.entrypoints=https-external"
      - "traefik.http.routers.guacamole-router.tls=true"
      - "traefik.http.routers.guacamole-router.tls.certresolver=dns-cloudflare"

  # Guacamole Service
      - "traefik.http.services.guacamole.loadbalancer.server.port=8080"

```

Still error 404, I am not very confortable with redirect and regex 🙂

---

<div class="post-metadata">

### Author: ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)
#### Post date: [March 5, 2025, 9:26am UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/4 "2025-03-05T09:26:49Z")

</div>

Tested and working 🙂

```auto
  guacamole:
    image: guacamole/guacamole
    networks:
      - proxy
      - database
    labels:
      - traefik.enable=true
      - traefik.docker.network=proxy

      # regular guacamole router
      - traefik.http.routers.myguacamole.rule=Host(`guacamole.example.com`)
      - traefik.http.services.myguacamole.loadbalancer.server.port=8080

      # redirect guacamole router for request without path, from / to /guacamole
      - traefik.http.routers.myguacamole-redir.rule=Host(`guacamole.example.com`) && Path(`/`)
      - traefik.http.routers.myguacamole-redir.middlewares=myguacamole-redir
      - traefik.http.middlewares.myguacamole-redir.redirectregex.regex=(.*)
      - traefik.http.middlewares.myguacamole-redir.redirectregex.replacement=$${1}guacamole

    environment:
      - GUACD_HOSTNAME=localhost
      - POSTGRESQL_DATABASE=localhost
      - POSTGRESQL_HOSTNAME=localhost
      - POSTGRESQL_USER=a
      - POSTGRESQL_PASSWORD=b
      - POSTGRESQL_DATABASE=c

```

You can enter `guacamole.example.com` into your client/browser, Traefik will automatically redirect you to `guacamole.example.com/guacamole`, so you never have to type in the path.

---

<div class="post-metadata">

### Author: ![ThierryIT](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thierryit/32/8446_2.png) [@ThierryIT](https://community.traefik.io/u/ThierryIT)
#### Post date: [March 5, 2025, 9:36am UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/5 "2025-03-05T09:36:43Z")

</div>

I still do have the same pb ...  
I have to add the TLS config to your config ...

---

<div class="post-metadata">

### Author: ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)
#### Post date: [March 5, 2025, 9:47am UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/6 "2025-03-05T09:47:12Z")

</div>

Place TLS config on `entrypoint`, reduces repeated config on `routers`.

---

<div class="post-metadata">

### Author: ![ThierryIT](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thierryit/32/8446_2.png) [@ThierryIT](https://community.traefik.io/u/ThierryIT)
#### Post date: [March 5, 2025, 9:56am UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/7 "2025-03-05T09:56:39Z")

</div>

```auto
- "traefik.enable=true"
      - "traefik.docker.network=mynet"

      # regular guacamole router
      - "traefik.http.routers.myguacamole.entrypoints=https-external"
      - "traefik.http.routers.myguacamole.tls=true"
      - "traefik.http.routers.myguacamole.tls.certresolver=dns-cloudflare"
      #- "traefik.http.routers.myguacamole.rule=Host(`guacamole.domain.org`)"
      - "traefik.http.services.myguacamole.loadbalancer.server.port=8080"
      

      # redirect guacamole router for request without path, from / to /guacamole
      - "traefik.http.routers.myguacamole-redir.rule=Host(`guacamole.domain.org`) && Path(`/`)"
      - "traefik.http.routers.myguacamole-redir.middlewares=myguacamole-redir"
      - "traefik.http.middlewares.myguacamole-redir.redirectregex.regex=(.*)"
      - "traefik.http.middlewares.myguacamole-redir.redirectregex.replacement=$${1}guacamole"

```

I didn't understood what you have "said" ... sorry

---

<div class="post-metadata">

### Author: ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)
#### Post date: [March 5, 2025, 12:46pm UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/8 "2025-03-05T12:46:31Z")

</div>

Your labels are incomplete. You have two `routers`. Both need a `rule`. And if you set TLS on `routers` (not globally on `entrypoint`), then both need `tls`.

Check [simple Traefik example](https://github.com/bluepuma77/traefik-best-practice/tree/main/docker-traefik-dashboard-letsencrypt) for a best practice configuration.

---

<div class="post-metadata">

### Author: ![ThierryIT](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thierryit/32/8446_2.png) [@ThierryIT](https://community.traefik.io/u/ThierryIT)
#### Post date: [March 5, 2025, 1:32pm UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/9 "2025-03-05T13:32:43Z")

</div>

So I have two routers: `guacamole` and `guacamole-redir`  
I have add for each router:

```auto
- "traefik.http.routers.guacamole-redir.tls=true" or - "traefik.http.routers.guacamole.tls=true" and the resolver for each

```

I hope this is correct.  
I do have a change concerning my pb. Now when typing `https://guacamole.domain.ff` it forward it to `https://guacamole.domain.ff/guacamole` (what I want) but I still have an error 404.

```auto
labels:
      - "traefik.enable=true"
      - "traefik.docker.network=mynet"
      # regular guacamole router
      - "traefik.http.routers.guacamole.entrypoints=https-external"
      - "traefik.http.services.guacamole.loadbalancer.server.port=8080"
      - "traefik.http.routers.guacamole.tls=true"
      # redirect guacamole router for request without path, from / to /guacamole
      - "traefik.http.routers.guacamole-redir.rule=Host(`guacamole.domain.org`) && Path(`/`)"
      - "traefik.http.routers.guacamole-redir.tls=true"
      - "traefik.http.routers.guacamole-redir.middlewares=guacamole-redir"
      - "traefik.http.middlewares.guacamole-redir.redirectregex.regex=(.*)"
      - "traefik.http.middlewares.guacamole-redir.redirectregex.replacement=$${1}guacamole"

```

---

<div class="post-metadata">

### Author: ![ThierryIT](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thierryit/32/8446_2.png) [@ThierryIT](https://community.traefik.io/u/ThierryIT)
#### Post date: [March 5, 2025, 3:59pm UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/10 "2025-03-05T15:59:14Z")

</div>

```auto
2025-03-05T17:57:52+02:00 ERR Unable to obtain ACME certificate for domains error="unable to generate a certificate for the domains [guacamole-guacamole]: acme: error: 400 :: POST :: https://acme-v02.api.letsencrypt.org/acme/new-order :: urn:ietf:params:acme:error:rejectedIdentifier :: Invalid identifiers requested :: Cannot issue for \"guacamole-guacamole\": Domain name needs at least one dot" ACME CA=https://acme-v02.api.letsencrypt.org/directory acmeCA=https://acme-v02.api.letsencrypt.org/directory domains=["guacamole-guacamole"] providerName=dns-cloudflare.acme routerName=guacamole@docker rule=Host(`guacamole-guacamole`)

```

Is it the problem when not using `staging` for the ssl ? To many request ?

```auto
Cannot issue for \"guacamole-guacamole\": Domain name needs at least one dot 

```

Where is that coming from ??

---

<div class="post-metadata">

### Author: ![ThierryIT](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thierryit/32/8446_2.png) [@ThierryIT](https://community.traefik.io/u/ThierryIT)
#### Post date: [March 5, 2025, 4:50pm UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/11 "2025-03-05T16:50:15Z")

</div>

```auto
labels:
      - "traefik.enable=true"
      - "traefik.docker.network=mynet"
      # regular guacamole router
      - "traefik.http.routers.guacamole.entrypoints=https-external"
      - "traefik.http.services.guacamole.loadbalancer.server.port=8080"
      - "traefik.http.routers.guacamole.tls=true"
      - "traefik.http.routers.guacamole.tls.certresolver=dns-cloudflare"
      # redirect guacamole router for request without path, from / to /guacamole
      - "traefik.http.routers.guacamole.rule=Host(`guacamole.domain.org`) && Path(`/`)"
      - "traefik.http.routers.guacamole.middlewares=guacamole@docker"
      - "traefik.http.middlewares.guacamole.redirectregex.regex=(.*)"
      - "traefik.http.middlewares.guacamole.redirectregex.replacement=$${1}guacamole"

```

I have removed the second router (guacamole-redir) to make this config a bit less messy ...  
I do not have anymore the SSL error 400 .... But still the 404.

---

<div class="post-metadata">

### Author: ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)
#### Post date: [March 5, 2025, 5:26pm UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/12 "2025-03-05T17:26:16Z")

</div>

I would recommend to follow my instructions:

> [@bluepuma77](#):
>
> You have two `routers`. Both need a `rule`.

---

<div class="post-metadata">

### Author: ![ThierryIT](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thierryit/32/8446_2.png) [@ThierryIT](https://community.traefik.io/u/ThierryIT)
#### Post date: [March 5, 2025, 5:49pm UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/13 "2025-03-05T17:49:54Z")

</div>

Yes I do apologie, I haven't very well undertand the concept of a traefik router. I have add the 2 rules for each router, it is now working.  
Thx a lot for your support.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)
#### Post date: [March 8, 2025, 5:50pm UTC](https://community.traefik.io/t/guacamole-behind-traefik-v3-3-4-pb-with-pathprefix/26743/14 "2025-03-08T17:50:19Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
