dokploy icon indicating copy to clipboard operation
dokploy copied to clipboard

https and www redirections in Compose services

Open QuentinMacheda opened this issue 7 months ago • 4 comments

What problem will this feature address?

Unlike application services, compose services do not have a "Redirects" setting, allowing the users to redirect from non-www to www for example. Therefore, I cannot have a redirection from domain.com to www.domain.com.

Describe the solution you'd like

A "Redirects" setting in compose services, allowing the user to add a redirection, like in the application services.

Describe alternatives you've considered

I did not find any alternative solutions or workaround so far.

Additional context

No response

Will you send a PR to implement it?

Maybe, need help

QuentinMacheda avatar May 27 '25 23:05 QuentinMacheda

When you go to 'Traefik File System' you could add a middleware in middlewares.yml like this:

redirect-to-www:
      redirectRegex:
        regex: ^https://domain\.com/?$
        replacement: https://www.domain.com
        permanent: true

In your compose file you would then need to add this label to your service:

labels:
      - traefik.http.routers.<service_name>.middlewares=redirect-to-www@file

The service_name can be found if you click 'Preview Compose' in the top right of the provider section (search for this line - traefik.http.routers.<container_name>-<some_number>-websecure.service=<container_name>-<some_number>-websecure)

ThePaulo1 avatar Jul 17 '25 22:07 ThePaulo1

When you go to 'Traefik File System' you could add a middleware in middlewares.yml like this:

redirect-to-www:
      redirectRegex:
        regex: ^https://domain\.com/?$
        replacement: https://www.domain.com
        permanent: true

In your compose file you would then need to add this label to your service:

labels:
      - traefik.http.routers.<service_name>.middlewares=redirect-to-www@file

The service_name can be found if you click 'Preview Compose' in the top right of the provider section (search for this line - traefik.http.routers.<container_name>-<some_number>-websecure.service=<container_name>-<some_number>-websecure)

Is this really a viable solution? How are you dealing with labels added by dokploy and the container name randomization?

b3nab avatar Sep 26 '25 20:09 b3nab

When adding labels yourself those will just get appended to the ones dokploy generated. Container name is randomized on creation but then stays the same, so you can safely copy the service name from the compose preview as described

ThePaulo1 avatar Sep 27 '25 10:09 ThePaulo1

It would be great to have the one-click option in Compose.

Image

joanproductivo avatar Nov 10 '25 13:11 joanproductivo