[solved] custom domain doesn't work with `redirect-to-https` middleware in dokploy config.

I've got this config, this works but if I uncomment middlware - redirect-to-https it doesn't work (which is default config), any ideas ? I've been using nginx never used traefik, is it intended or ?
routers:
dokploy-router-app:
rule: Host(`console.algosensei.org`)
service: dokploy-service-app
entryPoints:
- web
# middlewares:
# - redirect-to-https
dokploy-router-app-secure:
rule: Host(`console.algosensei.org`)
service: dokploy-service-app
entryPoints:
- websecure
middlewares:
- redirect-to-https
tls:
certResolver: letsencrypt
routers:
dokploy-router-app:
rule: Host(`console.algosensei.org`)
service: dokploy-service-app
entryPoints:
- web
# middlewares:
# - redirect-to-https
dokploy-router-app-secure:
rule: Host(`console.algosensei.org`)
service: dokploy-service-app
entryPoints:
- websecure
middlewares:
- redirect-to-https
tls:
certResolver: letsencrypt
19 Replies
Henrik
Henrik2mo ago
The websecure router shouldn't have the redirect option middleware. Traefik logs usually points out what's wrong when the config is not working
iamarpit
iamarpitOP2mo ago
I've tried that as well, adding redirect-to-https in web and removing it from websecure but still not working.. it keeps on redirecting, so I get that http to https valid, and websecure just stay as it is.. but then it was not working.
routers:
dokploy-router-app:
rule: Host(`console.algosensei.org`)
service: dokploy-service-app
entryPoints:
- web
middlewares:
- redirect-to-https
dokploy-router-app-secure:
rule: Host(`console.algosensei.org`)
service: dokploy-service-app
entryPoints:
- websecure
# middlewares:
# - redirect-to-https
tls:
certResolver: letsencrypt
routers:
dokploy-router-app:
rule: Host(`console.algosensei.org`)
service: dokploy-service-app
entryPoints:
- web
middlewares:
- redirect-to-https
dokploy-router-app-secure:
rule: Host(`console.algosensei.org`)
service: dokploy-service-app
entryPoints:
- websecure
# middlewares:
# - redirect-to-https
tls:
certResolver: letsencrypt
Henrik
Henrik2mo ago
I'm not sure why you're trying to edit the file manually. There usually few reasons to do that. I assume the service also exists? It's the default dokploy router so it should
iamarpit
iamarpitOP2mo ago
yhh service is also there I'm just giving you the relavent config, I just added domain to webserver but it wasn't working so I disabled middleware in websecure still no changes, then I disabled middlware in web and it worked... just wanted to know why ? bcoz it should be the other way around
Henrik
Henrik2mo ago
Weird. How you played around with any other Traefik files?
iamarpit
iamarpitOP2mo ago
the file system ??, I dunno what you mean tbh
No description
Henrik
Henrik2mo ago
Yes I mean the files there
iamarpit
iamarpitOP2mo ago
so, this is my complete config
http:
routers:
dokploy-router-app:
rule: Host(`console.algosensei.org`)
service: dokploy-service-app
entryPoints:
- web
middlewares:
- redirect-to-https
dokploy-router-app-secure:
rule: Host(`console.algosensei.org`)
service: dokploy-service-app
entryPoints:
- websecure
# middlewares:
# - redirect-to-https
tls:
certResolver: letsencrypt
services:
dokploy-service-app:
loadBalancer:
servers:
- url: http://dokploy:3000
passHostHeader: true
http:
routers:
dokploy-router-app:
rule: Host(`console.algosensei.org`)
service: dokploy-service-app
entryPoints:
- web
middlewares:
- redirect-to-https
dokploy-router-app-secure:
rule: Host(`console.algosensei.org`)
service: dokploy-service-app
entryPoints:
- websecure
# middlewares:
# - redirect-to-https
tls:
certResolver: letsencrypt
services:
dokploy-service-app:
loadBalancer:
servers:
- url: http://dokploy:3000
passHostHeader: true
should work but its not working
Henrik
Henrik2mo ago
From a quick glance, that looks correct. Check Traefik logs
iamarpit
iamarpitOP2mo ago
cool, lemme check your status is good one I found this in logs
2025-03-27T07:58:37Z ERR Error while starting server error="accept tcp [::]:443: use of closed network connection" entryPointName=websecure
2025-03-27T07:58:37Z ERR Error while starting server error="accept tcp [::]:80: use of closed network connection" entryPointName=web
2025-03-27T07:58:37Z ERR Error while starting server error="accept tcp [::]:443: use of closed network connection" entryPointName=websecure
2025-03-27T07:58:37Z ERR Error while starting server error="accept tcp [::]:80: use of closed network connection" entryPointName=web
Henrik
Henrik2mo ago
Have you checked your firewall? Is port 80 and 443 open? On 443 check that it also allows for UDP traffic
iamarpit
iamarpitOP2mo ago
it was cloudflare 👀 , changed mode from flexible to full strict and its solved. this helped... thanks bud.. cheers 🍻
root@ubuntu:~# curl -I https://console.algosensei.org
HTTP/2 308
date: Thu, 27 Mar 2025 08:30:01 GMT
content-length: 18
location: https://console.algosensei.org/
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 926d85f808c347c1-BOM
alt-svc: h3=":443"; ma=86400
server-timing: cfL4;desc="?
root@ubuntu:~# curl -I https://console.algosensei.org
HTTP/2 308
date: Thu, 27 Mar 2025 08:30:01 GMT
content-length: 18
location: https://console.algosensei.org/
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 926d85f808c347c1-BOM
alt-svc: h3=":443"; ma=86400
server-timing: cfL4;desc="?
@Henrik there is one thing thoug, on domain routing is a bit slow. vs on ip it was almost instant,.. ideas ?
iamarpit
iamarpitOP2mo ago
I've added ip vs domain fetches.
No description
No description
iamarpit
iamarpitOP2mo ago
93ms vs 1.5 seconds
Henrik
Henrik2mo ago
Slow DNS maybe
iamarpit
iamarpitOP2mo ago
am using cloudflare, any other suggestions bud.. should I try switching to other services ?
Henrik
Henrik2mo ago
I would guess it's a DNS propagation issue. Give it some time to let the record reach other authoritative servers.
iamarpit
iamarpitOP2mo ago
I've changed the dns like two weeks ago..
Henrik
Henrik2mo ago
Lol. I have no clue

Did you find this page helpful?