diff --git a/server/lib/traefik/getTraefikConfig.ts b/server/lib/traefik/getTraefikConfig.ts index 3169158f..4aea2bff 100644 --- a/server/lib/traefik/getTraefikConfig.ts +++ b/server/lib/traefik/getTraefikConfig.ts @@ -60,11 +60,6 @@ export async function getTraefikConfig( proxyProtocol: resources.proxyProtocol, proxyProtocolVersion: resources.proxyProtocolVersion, - maintenanceModeEnabled: resources.maintenanceModeEnabled, - maintenanceModeType: resources.maintenanceModeType, - maintenanceTitle: resources.maintenanceTitle, - maintenanceMessage: resources.maintenanceMessage, - maintenanceEstimatedTime: resources.maintenanceEstimatedTime, // Target fields targetId: targets.targetId, targetEnabled: targets.enabled, @@ -187,11 +182,6 @@ export async function getTraefikConfig( // Store domain cert resolver fields domainCertResolver: row.domainCertResolver, preferWildcardCert: row.preferWildcardCert - maintenanceModeEnabled: row.maintenanceModeEnabled, - maintenanceModeType: row.maintenanceModeType, - maintenanceTitle: row.maintenanceTitle, - maintenanceMessage: row.maintenanceMessage, - maintenanceEstimatedTime: row.maintenanceEstimatedTime, }); } @@ -257,97 +247,6 @@ export async function getTraefikConfig( config_output.http.services = {}; } - // available healthy servers for automatic mode - const availableServers = (targets as TargetWithSite[]).filter( - (target: TargetWithSite) => { - if (!target.enabled) return false; - - const anySitesOnline = (targets as TargetWithSite[]).some( - (t: TargetWithSite) => t.site.online - ); - if (anySitesOnline && !target.site.online) return false; - - if (target.site.type === "local" || target.site.type === "wireguard") { - return target.ip && target.port && target.method; - } else if (target.site.type === "newt") { - return target.internalPort && target.method && target.site.subnet; - } - return false; - } - ); - - const hasHealthyServers = availableServers.length > 0; - - let showMaintenancePage = false; - if (resource.maintenanceModeEnabled) { - if (resource.maintenanceModeType === "forced") { - showMaintenancePage = true; - logger.debug( - `Resource ${resource.name} (${fullDomain}) is in FORCED maintenance mode` - ); - } else if (resource.maintenanceModeType === "automatic") { - showMaintenancePage = !hasHealthyServers; - if (showMaintenancePage) { - logger.warn( - `Resource ${resource.name} (${fullDomain}) has no healthy servers - showing maintenance page (AUTOMATIC mode)` - ); - } - } - } - - if (showMaintenancePage) { - const maintenanceServiceName = `${key}-maintenance-service`; - const maintenanceRouterName = `${key}-maintenance-router`; - - const maintenancePort = config.getRawConfig().traefik.maintenance_port || 8888; - const entrypointHttp = config.getRawConfig().traefik.http_entrypoint; - const entrypointHttps = config.getRawConfig().traefik.https_entrypoint; - - const fullDomain = resource.fullDomain; - const domainParts = fullDomain.split("."); - const wildCard = resource.subdomain - ? `*.${domainParts.slice(1).join(".")}` - : fullDomain; - - const tls = { - certResolver: resource.domainCertResolver?.trim() || - config.getRawConfig().traefik.cert_resolver, - ...(config.getRawConfig().traefik.prefer_wildcard_cert - ? { domains: [{ main: wildCard }] } - : {}) - }; - - const maintenanceHost = config.getRawConfig().traefik?.maintenance_host || 'pangolin'; - - config_output.http.services[maintenanceServiceName] = { - loadBalancer: { - servers: [{ url: `http://${maintenanceHost}:${maintenancePort}` }], - passHostHeader: true - } - }; - - const rule = `Host(\`${fullDomain}\`)`; - - config_output.http.routers[maintenanceRouterName] = { - entryPoints: [resource.ssl ? entrypointHttps : entrypointHttp], - service: maintenanceServiceName, - rule, - priority: 2000, - ...(resource.ssl ? { tls } : {}) - }; - - if (resource.ssl) { - config_output.http.routers[`${maintenanceRouterName}-redirect`] = { - entryPoints: [entrypointHttp], - middlewares: [redirectHttpsMiddlewareName], - service: maintenanceServiceName, - rule, - priority: 2000 - }; - } - - continue; - } const domainParts = fullDomain.split("."); let wildCard; if (domainParts.length <= 2) {