coollabsio / coolify

An open-source & self-hostable Heroku / Netlify / Vercel alternative.
https://coolify.io
Apache License 2.0
34.24k stars 1.86k forks source link

[Bug]: Permanent redirection for https does not work #3337

Open hamanuha opened 2 months ago

hamanuha commented 2 months ago

Description

I‘m trying to get a 301 redirection instead of a 302 for the http to https redirection for a static service. I added this to the Traefik labels:

traefik.http.middlewares.redirect-to-https.redirectscheme.permanent=true

But then the redirect isn’t working at all and I get a 404 instead if I access the site with http.

Minimal Reproduction (if possible, example repository)

Exception or Error

No response

Version

beta.323

Cloud?

hamanuha commented 1 month ago

I solved this. This has to be added to all services because that’s a global rule and then there is a mismatch.

Can this label be moved out of the service definition into the global config? Or should it be scoped to each service?

stuartbgreen commented 1 month ago

+1 same issue here. Another way to solve it is to give a different name to the middleware for the service you want to change, e.g. changing redirect-to-https to an arbitrary name like myservicename-redirect-to-https

example:


traefik.http.middlewares.myservicename-redirect-to-https.redirectscheme.scheme=https
traefik.http.middlewares.myservicename-redirect-to-https.redirectscheme.permanent=true

# also update routers to use the new name
traefik.http.routers.http-0-bk0k8g80sgo4c8o0g0g0008c.middlewares=myservicename-redirect-to-https
traefik.http.routers.http-1-bk0k8g80sgo4c8o0g0g0008c.middlewares=myservicename-redirect-to-https