mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-16 15:32:19 +02:00
infer wild card cert if prefer flag is on
This commit is contained in:
parent
5c80f026bc
commit
e279d93570
2 changed files with 26 additions and 4 deletions
|
@ -29,6 +29,7 @@ const environmentSchema = z.object({
|
||||||
http_entrypoint: z.string(),
|
http_entrypoint: z.string(),
|
||||||
https_entrypoint: z.string().optional(),
|
https_entrypoint: z.string().optional(),
|
||||||
cert_resolver: z.string().optional(),
|
cert_resolver: z.string().optional(),
|
||||||
|
prefer_wildcard_cert: z.boolean().optional(),
|
||||||
}),
|
}),
|
||||||
gerbil: z.object({
|
gerbil: z.object({
|
||||||
start_port: portSchema,
|
start_port: portSchema,
|
||||||
|
|
|
@ -34,10 +34,6 @@ export async function traefikConfigProvider(
|
||||||
|
|
||||||
// const baseDomain = new URL(config.app.base_url).hostname;
|
// const baseDomain = new URL(config.app.base_url).hostname;
|
||||||
|
|
||||||
const tls = {
|
|
||||||
certResolver: config.traefik.cert_resolver,
|
|
||||||
};
|
|
||||||
|
|
||||||
const http: any = {
|
const http: any = {
|
||||||
routers: {},
|
routers: {},
|
||||||
services: {},
|
services: {},
|
||||||
|
@ -68,6 +64,31 @@ export async function traefikConfigProvider(
|
||||||
const routerName = `${target.targetId}-router`;
|
const routerName = `${target.targetId}-router`;
|
||||||
const serviceName = `${target.targetId}-service`;
|
const serviceName = `${target.targetId}-service`;
|
||||||
|
|
||||||
|
if (!resource.fullDomain) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const domainParts = resource.fullDomain.split(".");
|
||||||
|
let wildCard;
|
||||||
|
if (domainParts.length <= 2) {
|
||||||
|
wildCard = `*.${domainParts.join(".")}`;
|
||||||
|
} else {
|
||||||
|
wildCard = `*.${domainParts.slice(1).join(".")}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tls = {
|
||||||
|
certResolver: config.traefik.cert_resolver,
|
||||||
|
...(config.traefik.prefer_wildcard_cert
|
||||||
|
? {
|
||||||
|
domains: [
|
||||||
|
{
|
||||||
|
main: wildCard
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
};
|
||||||
|
|
||||||
http.routers![routerName] = {
|
http.routers![routerName] = {
|
||||||
entryPoints: [
|
entryPoints: [
|
||||||
target.ssl
|
target.ssl
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue