mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-29 14:18:26 +02:00
Trying to get this to work
This commit is contained in:
parent
fd806f5061
commit
7e457c548e
1 changed files with 15 additions and 11 deletions
|
@ -59,6 +59,8 @@ export async function traefikConfigProvider(
|
||||||
)
|
)
|
||||||
.groupBy(resources.resourceId);
|
.groupBy(resources.resourceId);
|
||||||
|
|
||||||
|
logger.debug(JSON.stringify(allResources, null, 2));
|
||||||
|
|
||||||
if (!allResources.length) {
|
if (!allResources.length) {
|
||||||
return res.status(HttpCode.OK).json({});
|
return res.status(HttpCode.OK).json({});
|
||||||
}
|
}
|
||||||
|
@ -149,7 +151,9 @@ export async function traefikConfigProvider(
|
||||||
: {})
|
: {})
|
||||||
};
|
};
|
||||||
|
|
||||||
logger.debug(config.getRawConfig().traefik.prefer_wildcard_cert)
|
logger.debug(
|
||||||
|
config.getRawConfig().traefik.prefer_wildcard_cert
|
||||||
|
);
|
||||||
|
|
||||||
const additionalMiddlewares =
|
const additionalMiddlewares =
|
||||||
config.getRawConfig().traefik.additional_middlewares || [];
|
config.getRawConfig().traefik.additional_middlewares || [];
|
||||||
|
@ -176,7 +180,7 @@ export async function traefikConfigProvider(
|
||||||
],
|
],
|
||||||
middlewares: [redirectHttpsMiddlewareName],
|
middlewares: [redirectHttpsMiddlewareName],
|
||||||
service: serviceName,
|
service: serviceName,
|
||||||
rule: convertUrlToTraefikRegex(fullDomain),
|
rule: convertUrlToTraefikRegex(fullDomain)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,18 +302,18 @@ export async function traefikConfigProvider(
|
||||||
|
|
||||||
function convertUrlToTraefikRegex(url: string): string {
|
function convertUrlToTraefikRegex(url: string): string {
|
||||||
// Check if the URL contains a wildcard
|
// Check if the URL contains a wildcard
|
||||||
if (!url.includes('*')) {
|
if (!url.includes("*")) {
|
||||||
return `Host(\`${url}\`)`;
|
return `Host(\`${url}\`)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escape dots and replace wildcard with regex pattern
|
// Escape dots and replace wildcard with regex pattern
|
||||||
// Handle the case where * already has dots around it
|
// Handle the case where * already has dots around it
|
||||||
const regexPattern = url
|
const regexPattern = url
|
||||||
.replace(/\./g, '\\.') // First escape all dots
|
.replace(/\./g, "\\.") // First escape all dots
|
||||||
.replace(/\\\.\*\\\./g, '.+\\.') // Replace \.*.\ with .+\.
|
.replace(/\\\.\*\\\./g, ".+\\.") // Replace \.*.\ with .+\.
|
||||||
.replace(/\*\\\./g, '.+\\.') // Replace *.\ with .+\.
|
.replace(/\*\\\./g, ".+\\.") // Replace *.\ with .+\.
|
||||||
.replace(/\\\.\*/g, '\\.+') // Replace \.* with \.+
|
.replace(/\\\.\*/g, "\\.+") // Replace \.* with \.+
|
||||||
.replace(/\*/g, '.+'); // Replace any remaining * with .+
|
.replace(/\*/g, ".+"); // Replace any remaining * with .+
|
||||||
|
|
||||||
return `HostRegexp(\`^${regexPattern}$\`)`;
|
return `HostRegexp(\`^${regexPattern}$\`)`;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue