mirror of
https://github.com/fosrl/pangolin.git
synced 2026-09-23 02:52:58 +02:00
Dont load private resource inference without a exit node loaded
This commit is contained in:
@@ -767,8 +767,7 @@ export async function getTraefikConfig(
|
||||
if (!config_output.http.middlewares) {
|
||||
config_output.http.middlewares = {};
|
||||
}
|
||||
config_output.http.middlewares[aiGatewayTrustMiddlewareNameResource] =
|
||||
{
|
||||
config_output.http.middlewares[aiGatewayTrustMiddlewareNameResource] = {
|
||||
headers: {
|
||||
customRequestHeaders: {
|
||||
[AI_GATEWAY_TRUST_HEADER]: getAiGatewayTrustToken(),
|
||||
@@ -798,8 +797,7 @@ export async function getTraefikConfig(
|
||||
const enableAiGatewayClientIpHeader =
|
||||
config.getRawConfig().server.enable_ai_gateway_client_ip_header;
|
||||
if (enableAiGatewayClientIpHeader) {
|
||||
config_output.http.middlewares[aiGatewayClientIpMiddlewareName] =
|
||||
{
|
||||
config_output.http.middlewares[aiGatewayClientIpMiddlewareName] = {
|
||||
plugin: {
|
||||
badger: {
|
||||
disableForwardAuth: true,
|
||||
@@ -935,11 +933,14 @@ export async function getTraefikConfig(
|
||||
)
|
||||
);
|
||||
|
||||
if (exitNode) {
|
||||
for (const sr of siteResourcesInference) {
|
||||
if (!sr.enabled || !sr.fullDomain) continue;
|
||||
|
||||
if (!config_output.http.routers) config_output.http.routers = {};
|
||||
if (!config_output.http.services) config_output.http.services = {};
|
||||
if (!config_output.http.routers)
|
||||
config_output.http.routers = {};
|
||||
if (!config_output.http.services)
|
||||
config_output.http.services = {};
|
||||
|
||||
const fullDomain = sr.fullDomain;
|
||||
const srKey = `inference-sr${sr.siteResourceId}`;
|
||||
@@ -1021,6 +1022,7 @@ export async function getTraefikConfig(
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config_output;
|
||||
}
|
||||
|
||||
@@ -1581,8 +1581,7 @@ export async function getTraefikConfig(
|
||||
"ai-gateway-trust-headers-resource";
|
||||
const aiGatewayTrustMiddlewareNameSiteResource =
|
||||
"ai-gateway-trust-headers-site-resource";
|
||||
config_output.http.middlewares[aiGatewayTrustMiddlewareNameResource] =
|
||||
{
|
||||
config_output.http.middlewares[aiGatewayTrustMiddlewareNameResource] = {
|
||||
headers: {
|
||||
customRequestHeaders: {
|
||||
[AI_GATEWAY_TRUST_HEADER]: getAiGatewayTrustToken(),
|
||||
@@ -1612,8 +1611,7 @@ export async function getTraefikConfig(
|
||||
const enableAiGatewayClientIpHeader =
|
||||
config.getRawConfig().server.enable_ai_gateway_client_ip_header;
|
||||
if (enableAiGatewayClientIpHeader) {
|
||||
config_output.http.middlewares[aiGatewayClientIpMiddlewareName] =
|
||||
{
|
||||
config_output.http.middlewares[aiGatewayClientIpMiddlewareName] = {
|
||||
plugin: {
|
||||
badger: {
|
||||
disableForwardAuth: true,
|
||||
@@ -1742,6 +1740,7 @@ export async function getTraefikConfig(
|
||||
};
|
||||
}
|
||||
|
||||
if (exitNode) {
|
||||
// Private (siteResource) inference resources: routed by their alias
|
||||
// instead of a public fullDomain, and deliberately WITHOUT the
|
||||
// badger middleware - no per-user auth/policy stack exists for
|
||||
@@ -1750,8 +1749,10 @@ export async function getTraefikConfig(
|
||||
for (const sr of siteResourcesInference) {
|
||||
if (!sr.enabled || !sr.fullDomain) continue;
|
||||
|
||||
if (!config_output.http.routers) config_output.http.routers = {};
|
||||
if (!config_output.http.services) config_output.http.services = {};
|
||||
if (!config_output.http.routers)
|
||||
config_output.http.routers = {};
|
||||
if (!config_output.http.services)
|
||||
config_output.http.services = {};
|
||||
|
||||
const fullDomain = sr.fullDomain;
|
||||
const srKey = `inference-sr${sr.siteResourceId}`;
|
||||
@@ -1760,7 +1761,9 @@ export async function getTraefikConfig(
|
||||
const rule = `Host(\`${fullDomain}\`) && ClientIP(\`${exitNode.address}\`)`; // restrict to coming from the exit node ip range that the client is connected to
|
||||
|
||||
let tls: any = {};
|
||||
if (!privateConfig.getRawPrivateConfig().flags.use_pangolin_dns) {
|
||||
if (
|
||||
!privateConfig.getRawPrivateConfig().flags.use_pangolin_dns
|
||||
) {
|
||||
const domainParts = fullDomain.split(".");
|
||||
const wildCard =
|
||||
domainParts.length <= 2
|
||||
@@ -1804,7 +1807,9 @@ export async function getTraefikConfig(
|
||||
config_output.http.middlewares[srHeadersMiddlewareName] = {
|
||||
headers: {
|
||||
customRequestHeaders: {
|
||||
...(aiGatewayHost ? { Host: aiGatewayHost } : {}),
|
||||
...(aiGatewayHost
|
||||
? { Host: aiGatewayHost }
|
||||
: {}),
|
||||
"p-host": fullDomain
|
||||
}
|
||||
}
|
||||
@@ -1846,6 +1851,7 @@ export async function getTraefikConfig(
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (generateLoginPageRouters) {
|
||||
const exitNodeLoginPages = await db
|
||||
|
||||
Reference in New Issue
Block a user