Skip to content

Commit 103e2f7

Browse files
authored
fix: add tls=true label for domains when certificateType is none (Dokploy#4018) (Dokploy#4474)
* fix: add tls=true label for compose domains when certificateType is none (Dokploy#4018) * test: cover tls=true label for certificateType none, require https * fix: scope tls fix to compose labels, leave traefik file config unchanged (Dokploy#4018)
1 parent 34d38cf commit 103e2f7

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

‎apps/dokploy/__test__/compose/domain/labels.test.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,51 @@ describe("createDomainLabels", () => {
103103
);
104104
});
105105

106+
it("should add tls=true for certificateType none on websecure entrypoint", async () => {
107+
const noneDomain = {
108+
...baseDomain,
109+
https: true,
110+
certificateType: "none" as const,
111+
};
112+
const labels = await createDomainLabels(appName, noneDomain, "websecure");
113+
expect(labels).toContain(
114+
"traefik.http.routers.test-app-1-websecure.tls=true",
115+
);
116+
// no cert resolver should be set when relying on a default/custom cert
117+
expect(labels).not.toContain(
118+
"traefik.http.routers.test-app-1-websecure.tls.certresolver=letsencrypt",
119+
);
120+
});
121+
122+
it("should not add tls=true for certificateType none on web entrypoint", async () => {
123+
const noneDomain = {
124+
...baseDomain,
125+
https: true,
126+
certificateType: "none" as const,
127+
};
128+
const labels = await createDomainLabels(appName, noneDomain, "web");
129+
expect(labels).not.toContain(
130+
"traefik.http.routers.test-app-1-web.tls=true",
131+
);
132+
});
133+
134+
it("should add tls=true for certificateType none on a custom https entrypoint", async () => {
135+
const noneDomain = {
136+
...baseDomain,
137+
https: true,
138+
customEntrypoint: "websecure-custom",
139+
certificateType: "none" as const,
140+
};
141+
const labels = await createDomainLabels(
142+
appName,
143+
noneDomain,
144+
"websecure-custom",
145+
);
146+
expect(labels).toContain(
147+
"traefik.http.routers.test-app-1-websecure-custom.tls=true",
148+
);
149+
});
150+
106151
it("should handle different ports correctly", async () => {
107152
const customPortDomain = { ...baseDomain, port: 3000 };
108153
const labels = await createDomainLabels(appName, customPortDomain, "web");

‎packages/server/src/utils/docker/domain.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ export const createDomainLabels = (
337337
labels.push(
338338
`traefik.http.routers.${routerName}.tls.certresolver=${customCertResolver}`,
339339
);
340+
} else if (certificateType === "none" && https) {
341+
// No cert resolver, but HTTPS is enabled (default/custom certificate):
342+
// explicitly enable TLS so Traefik serves the router over HTTPS.
343+
labels.push(`traefik.http.routers.${routerName}.tls=true`);
340344
}
341345
}
342346

0 commit comments

Comments
 (0)