mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
fix(traefik): update server configuration to use new host parameter and ensure HTTPS is set correctly
- Modified the updateServerTraefik function to utilize the newHost parameter instead of user.host. - Ensured the HTTPS field is correctly initialized in the test for server configuration.
This commit is contained in:
parent
e5a3e56e13
commit
bca6af77fd
@ -74,7 +74,6 @@ beforeEach(() => {
|
|||||||
|
|
||||||
test("Should read the configuration file", () => {
|
test("Should read the configuration file", () => {
|
||||||
const config: FileConfig = loadOrCreateConfig("dokploy");
|
const config: FileConfig = loadOrCreateConfig("dokploy");
|
||||||
|
|
||||||
expect(config.http?.routers?.["dokploy-router-app"]?.service).toBe(
|
expect(config.http?.routers?.["dokploy-router-app"]?.service).toBe(
|
||||||
"dokploy-service-app",
|
"dokploy-service-app",
|
||||||
);
|
);
|
||||||
@ -84,6 +83,7 @@ test("Should apply redirect-to-https", () => {
|
|||||||
updateServerTraefik(
|
updateServerTraefik(
|
||||||
{
|
{
|
||||||
...baseAdmin,
|
...baseAdmin,
|
||||||
|
https: true,
|
||||||
certificateType: "letsencrypt",
|
certificateType: "letsencrypt",
|
||||||
},
|
},
|
||||||
"example.com",
|
"example.com",
|
||||||
|
@ -15,7 +15,7 @@ export const updateServerTraefik = (
|
|||||||
user: User | null,
|
user: User | null,
|
||||||
newHost: string | null,
|
newHost: string | null,
|
||||||
) => {
|
) => {
|
||||||
const { https, host, certificateType } = user || {};
|
const { https, certificateType } = user || {};
|
||||||
const appName = "dokploy";
|
const appName = "dokploy";
|
||||||
const config: FileConfig = loadOrCreateConfig(appName);
|
const config: FileConfig = loadOrCreateConfig(appName);
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ export const updateServerTraefik = (
|
|||||||
config.http.services = config.http.services || {};
|
config.http.services = config.http.services || {};
|
||||||
|
|
||||||
const currentRouterConfig = config.http.routers[`${appName}-router-app`] || {
|
const currentRouterConfig = config.http.routers[`${appName}-router-app`] || {
|
||||||
rule: `Host(\`${host}\`)`,
|
rule: `Host(\`${newHost}\`)`,
|
||||||
service: `${appName}-service-app`,
|
service: `${appName}-service-app`,
|
||||||
entryPoints: ["web"],
|
entryPoints: ["web"],
|
||||||
};
|
};
|
||||||
@ -66,7 +66,7 @@ export const updateServerTraefik = (
|
|||||||
currentRouterConfig.middlewares = [];
|
currentRouterConfig.middlewares = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user?.host) {
|
if (newHost) {
|
||||||
writeTraefikConfig(config, appName);
|
writeTraefikConfig(config, appName);
|
||||||
} else {
|
} else {
|
||||||
removeTraefikConfig(appName);
|
removeTraefikConfig(appName);
|
||||||
|
Loading…
Reference in New Issue
Block a user