dokploy icon indicating copy to clipboard operation
dokploy copied to clipboard

Add support for configuring Traefik middleware such as StripPrefix

Open mhrlife opened this issue 1 year ago • 2 comments

What problem will this feature address?

Currently, when deploying applications with URL prefixes using Dokploy, there's no built-in option to configure Traefik middlewares like StripPrefix. This limitation requires manual modifications to the Traefik configuration after deployment. It makes it difficult to deploy applications that need URL prefix handling without additional manual steps.

Describe the solution you'd like

I would like Dokploy to provide the ability to configure Traefik middlewares through its deployment configurations. Specifically, adding support for the StripPrefix middleware would allow users to specify prefixes that Traefik should strip from incoming requests before forwarding them to backend services.

Describe alternatives you've considered

The alternative is to manually modify the Traefik configuration after deployment to include the necessary middleware. For example:

http:
  routers:
    my-app-router:
      rule: Host(`myapp.example.com`) && PathPrefix(`/chat`)
      service: my-app-service
      middlewares:
        - strip-chat-prefix
      entryPoints:
        - web

  middlewares:
    strip-chat-prefix:
      stripPrefix:
        prefixes:
          - "/chat"

However, this manual process is not ideal for automated deployments and can lead to inconsistencies across environments.

Additional context

No response

Will you send a PR to implement it?

No

mhrlife avatar Dec 06 '24 15:12 mhrlife

I have similar issues with middleware definitions for ipAllowList and basicAuth. Any attempt to apply these to routers via Docker labels doesn't work - they appear to be completely ignored. What is strange is that I can define them (via Docker labels) just fine (such as they appear in the Traefik console).

...
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.example-wordpress-test.rule=Host(`somehost.mycompany.co.uk`)"
      - "traefik.http.routers.example-wordpress-test.entrypoints=websecure"
      - "traefik.http.services.example-wordpress-test.loadbalancer.server.port=80"
      - "traefik.http.routers.example-wordpress-test.middlewares=MYauth@file" # Ignored, not applied
...

bigtob avatar Dec 09 '24 16:12 bigtob

Got the same issue. Hope we can have traefik middleware supports

binaryYuki avatar Dec 12 '24 23:12 binaryYuki

In my case, I wanted to add rate limiting middlewares to specific services. I managed to do it by modifying the Traefik configuration, but I had to redefine the routers for each service and reference them by their container names — which makes the setup quite fragile since those names can change

It would be great if this could be handled directly at the service level, so middlewares like rate limiting can be applied without redefining routers manually

franpek avatar Nov 04 '25 15:11 franpek