mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-30 06:29:23 +02:00
Handle oss tls
This commit is contained in:
parent
1f6379a7e6
commit
2c8bf4f18c
1 changed files with 19 additions and 21 deletions
|
@ -5,6 +5,7 @@ import logger from "@server/logger";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import config from "@server/lib/config";
|
import config from "@server/lib/config";
|
||||||
import { orgs, resources, sites, Target, targets } from "@server/db";
|
import { orgs, resources, sites, Target, targets } from "@server/db";
|
||||||
|
import { build } from "@server/build";
|
||||||
|
|
||||||
let currentExitNodeId: number;
|
let currentExitNodeId: number;
|
||||||
|
|
||||||
|
@ -52,12 +53,9 @@ export async function traefikConfigProvider(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getTraefikConfig(
|
export async function getTraefikConfig(exitNodeId: number): Promise<any> {
|
||||||
exitNodeId: number
|
|
||||||
): Promise<any> {
|
|
||||||
// Get all resources with related data
|
// Get all resources with related data
|
||||||
const allResources = await db.transaction(async (tx) => {
|
const allResources = await db.transaction(async (tx) => {
|
||||||
|
|
||||||
// Get the site(s) on this exit node
|
// Get the site(s) on this exit node
|
||||||
const resourcesWithRelations = await tx
|
const resourcesWithRelations = await tx
|
||||||
.select({
|
.select({
|
||||||
|
@ -86,10 +84,7 @@ export async function getTraefikConfig(
|
||||||
.from(resources)
|
.from(resources)
|
||||||
.innerJoin(sites, eq(sites.siteId, resources.siteId))
|
.innerJoin(sites, eq(sites.siteId, resources.siteId))
|
||||||
.where(
|
.where(
|
||||||
or(
|
or(eq(sites.exitNodeId, exitNodeId), isNull(sites.exitNodeId))
|
||||||
eq(sites.exitNodeId, exitNodeId),
|
|
||||||
isNull(sites.exitNodeId)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get all resource IDs from the first query
|
// Get all resource IDs from the first query
|
||||||
|
@ -134,7 +129,7 @@ export async function getTraefikConfig(
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!allResources.length) {
|
if (!allResources.length) {
|
||||||
return {}
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const badgerMiddlewareName = "badger";
|
const badgerMiddlewareName = "badger";
|
||||||
|
@ -236,18 +231,21 @@ export async function getTraefikConfig(
|
||||||
preferWildcardCert = configDomain.prefer_wildcard_cert;
|
preferWildcardCert = configDomain.prefer_wildcard_cert;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tls = {
|
let tls = {};
|
||||||
certResolver: certResolver,
|
if (build == "oss") {
|
||||||
...(preferWildcardCert
|
tls = {
|
||||||
? {
|
certResolver: certResolver,
|
||||||
domains: [
|
...(preferWildcardCert
|
||||||
{
|
? {
|
||||||
main: wildCard
|
domains: [
|
||||||
}
|
{
|
||||||
]
|
main: wildCard
|
||||||
}
|
}
|
||||||
: {})
|
]
|
||||||
};
|
}
|
||||||
|
: {})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const additionalMiddlewares =
|
const additionalMiddlewares =
|
||||||
config.getRawConfig().traefik.additional_middlewares || [];
|
config.getRawConfig().traefik.additional_middlewares || [];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue