mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-13 15:35:00 +02:00
build traefik config for newt correctly
This commit is contained in:
parent
a410abfaba
commit
658a6ca7bb
1 changed files with 27 additions and 9 deletions
|
@ -22,6 +22,10 @@ export async function traefikConfigProvider(
|
||||||
schema.orgs,
|
schema.orgs,
|
||||||
eq(schema.resources.orgId, schema.orgs.orgId),
|
eq(schema.resources.orgId, schema.orgs.orgId),
|
||||||
)
|
)
|
||||||
|
.innerJoin(
|
||||||
|
schema.sites,
|
||||||
|
eq(schema.sites.siteId, schema.resources.siteId),
|
||||||
|
)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(schema.targets.enabled, true),
|
eq(schema.targets.enabled, true),
|
||||||
|
@ -70,6 +74,7 @@ export async function traefikConfigProvider(
|
||||||
for (const item of all) {
|
for (const item of all) {
|
||||||
const target = item.targets;
|
const target = item.targets;
|
||||||
const resource = item.resources;
|
const resource = item.resources;
|
||||||
|
const site = item.sites;
|
||||||
const org = item.orgs;
|
const org = item.orgs;
|
||||||
|
|
||||||
const routerName = `${target.targetId}-router`;
|
const routerName = `${target.targetId}-router`;
|
||||||
|
@ -128,15 +133,28 @@ export async function traefikConfigProvider(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
http.services![serviceName] = {
|
if (site.type === "newt") {
|
||||||
loadBalancer: {
|
const ip = site.subnet.split("/")[0];
|
||||||
servers: [
|
http.services![serviceName] = {
|
||||||
{
|
loadBalancer: {
|
||||||
url: `${target.method}://${target.ip}:${target.port}`,
|
servers: [
|
||||||
},
|
{
|
||||||
],
|
url: `${target.method}://${ip}:${target.internalPort}`,
|
||||||
},
|
},
|
||||||
};
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
} else if (site.type === "wireguard") {
|
||||||
|
http.services![serviceName] = {
|
||||||
|
loadBalancer: {
|
||||||
|
servers: [
|
||||||
|
{
|
||||||
|
url: `${target.method}://${target.ip}:${target.port}`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.status(HttpCode.OK).json({ http });
|
return res.status(HttpCode.OK).json({ http });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue