From 7a66163216fb1808f613ff3682690b314cee77f6 Mon Sep 17 00:00:00 2001 From: Owen Date: Sun, 14 Sep 2025 20:33:06 -0700 Subject: [PATCH] Working on making blueprints work --- server/lib/blueprints/proxyResources.ts | 6 +++--- server/lib/blueprints/types.ts | 2 +- server/routers/traefik/getTraefikConfig.ts | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/server/lib/blueprints/proxyResources.ts b/server/lib/blueprints/proxyResources.ts index a66375dd..b8541518 100644 --- a/server/lib/blueprints/proxyResources.ts +++ b/server/lib/blueprints/proxyResources.ts @@ -107,7 +107,7 @@ export async function updateProxyResources( enabled: targetData.enabled, internalPort: internalPortToCreate, path: targetData.path, - pathMatchType: targetData.pathMatchType + pathMatchType: targetData["path-match"] }) .returning(); @@ -333,7 +333,7 @@ export async function updateProxyResources( port: targetData.port, enabled: targetData.enabled, path: targetData.path, - pathMatchType: targetData.pathMatchType + pathMatchType: targetData["path-match"] }) .where(eq(targets.targetId, existingTarget.targetId)) .returning(); @@ -424,7 +424,7 @@ export async function updateProxyResources( validateRule(rule); await trx.insert(resourceRules).values({ resourceId: existingResource.resourceId, - action: rule.action.toUpperCase(), + action: getRuleAction(rule.action), match: rule.match.toUpperCase(), value: rule.value, priority: index + 1 // start priorities at 1 diff --git a/server/lib/blueprints/types.ts b/server/lib/blueprints/types.ts index 2b2ce5ec..fe360e92 100644 --- a/server/lib/blueprints/types.ts +++ b/server/lib/blueprints/types.ts @@ -14,7 +14,7 @@ export const TargetSchema = z.object({ enabled: z.boolean().optional().default(true), "internal-port": z.number().int().min(1).max(65535).optional(), path: z.string().optional(), - pathMatchType: z.enum(["exact", "prefix", "regex"]).optional().nullable() + "path-match": z.enum(["exact", "prefix", "regex"]).optional().nullable() }); export type TargetData = z.infer; diff --git a/server/routers/traefik/getTraefikConfig.ts b/server/routers/traefik/getTraefikConfig.ts index 08c94ad0..ac24ba7f 100644 --- a/server/routers/traefik/getTraefikConfig.ts +++ b/server/routers/traefik/getTraefikConfig.ts @@ -348,7 +348,9 @@ export async function getTraefikConfig( } let rule = `Host(\`${fullDomain}\`)`; + let priority = 100; if (resource.path && resource.pathMatchType) { + priority += 1; // add path to rule based on match type if (resource.pathMatchType === "exact") { rule += ` && Path(\`${resource.path}\`)`; @@ -368,7 +370,7 @@ export async function getTraefikConfig( middlewares: routerMiddlewares, service: serviceName, rule: rule, - priority: 100, + priority: priority, ...(resource.ssl ? { tls } : {}) }; @@ -380,7 +382,7 @@ export async function getTraefikConfig( middlewares: [redirectHttpsMiddlewareName], service: serviceName, rule: rule, - priority: 100 + priority: priority }; }