mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-21 04:56:40 +02:00
Support the browser gateways on the remote nodes
This commit is contained in:
@@ -511,6 +511,12 @@ export class TraefikConfigManager {
|
|||||||
let traefikConfig;
|
let traefikConfig;
|
||||||
try {
|
try {
|
||||||
const currentExitNode = await getCurrentExitNodeId();
|
const currentExitNode = await getCurrentExitNodeId();
|
||||||
|
|
||||||
|
const maintenancePort = config.getRawConfig().server.next_port;
|
||||||
|
const maintenanceHost =
|
||||||
|
config.getRawConfig().server.internal_hostname;
|
||||||
|
const browserGatewayUiUrl = `http://${maintenanceHost}:${maintenancePort}`;
|
||||||
|
|
||||||
// logger.debug(`Fetching traefik config for exit node: ${currentExitNode}`);
|
// logger.debug(`Fetching traefik config for exit node: ${currentExitNode}`);
|
||||||
traefikConfig = await getTraefikConfig(
|
traefikConfig = await getTraefikConfig(
|
||||||
// this is called by the local exit node to get its own config
|
// this is called by the local exit node to get its own config
|
||||||
@@ -521,7 +527,8 @@ export class TraefikConfigManager {
|
|||||||
build == "saas"
|
build == "saas"
|
||||||
? false
|
? false
|
||||||
: config.getRawConfig().traefik.allow_raw_resources, // dont allow raw resources on saas otherwise use config
|
: config.getRawConfig().traefik.allow_raw_resources, // dont allow raw resources on saas otherwise use config
|
||||||
build != "oss" // generate browser gateway targets on cloud and enterprise
|
build != "oss", // generate maintenance pages on cloud and hybrid
|
||||||
|
browserGatewayUiUrl // generate browser gateway targets on cloud and hybrid
|
||||||
);
|
);
|
||||||
|
|
||||||
const domains = new Set<string>();
|
const domains = new Set<string>();
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export async function getTraefikConfig(
|
|||||||
generateLoginPageRouters = false, // UNUSED BUT USED IN PRIVATE
|
generateLoginPageRouters = false, // UNUSED BUT USED IN PRIVATE
|
||||||
allowRawResources = true,
|
allowRawResources = true,
|
||||||
allowMaintenancePage = true, // UNUSED BUT USED IN PRIVATE
|
allowMaintenancePage = true, // UNUSED BUT USED IN PRIVATE
|
||||||
allowBrowserGatewayResources = true
|
browserGatewayUiUrl: string | null = null // UNUSED BUT USED IN PRIVATE
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
// Get resources with their targets and sites in a single optimized query
|
// Get resources with their targets and sites in a single optimized query
|
||||||
// Start from sites on this exit node, then join to targets and resources
|
// Start from sites on this exit node, then join to targets and resources
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export async function getTraefikConfig(
|
|||||||
generateLoginPageRouters = false,
|
generateLoginPageRouters = false,
|
||||||
allowRawResources = true,
|
allowRawResources = true,
|
||||||
allowMaintenancePage = true,
|
allowMaintenancePage = true,
|
||||||
allowBrowserGatewayResources = true
|
browserGatewayUiUrl: string | null = null
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
// Get resources with their targets and sites in a single optimized query
|
// Get resources with their targets and sites in a single optimized query
|
||||||
// Start from sites on this exit node, then join to targets and resources
|
// Start from sites on this exit node, then join to targets and resources
|
||||||
@@ -317,7 +317,7 @@ export async function getTraefikConfig(
|
|||||||
BrowserGatewayResourceEntry
|
BrowserGatewayResourceEntry
|
||||||
>();
|
>();
|
||||||
|
|
||||||
if (allowBrowserGatewayResources) {
|
if (browserGatewayUiUrl) {
|
||||||
for (const row of resourcesWithTargetsAndSites) {
|
for (const row of resourcesWithTargetsAndSites) {
|
||||||
if (!["ssh", "vnc", "rdp"].includes(row.mode)) {
|
if (!["ssh", "vnc", "rdp"].includes(row.mode)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -1027,7 +1027,7 @@ export async function getTraefikConfig(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowBrowserGatewayResources) {
|
if (browserGatewayUiUrl) {
|
||||||
// Generate Traefik config for browser gateway resources
|
// Generate Traefik config for browser gateway resources
|
||||||
const browserGatewayPort = 39999;
|
const browserGatewayPort = 39999;
|
||||||
for (const [, bgResource] of browserGatewayResourcesMap.entries()) {
|
for (const [, bgResource] of browserGatewayResourcesMap.entries()) {
|
||||||
@@ -1129,10 +1129,6 @@ export async function getTraefikConfig(
|
|||||||
const entrypointHttps =
|
const entrypointHttps =
|
||||||
config.getRawConfig().traefik.https_entrypoint;
|
config.getRawConfig().traefik.https_entrypoint;
|
||||||
|
|
||||||
const maintenancePort = config.getRawConfig().server.next_port;
|
|
||||||
const maintenanceHost =
|
|
||||||
config.getRawConfig().server.internal_hostname;
|
|
||||||
|
|
||||||
if (!config_output.http.services)
|
if (!config_output.http.services)
|
||||||
config_output.http.services = {};
|
config_output.http.services = {};
|
||||||
if (!config_output.http.middlewares)
|
if (!config_output.http.middlewares)
|
||||||
@@ -1144,7 +1140,7 @@ export async function getTraefikConfig(
|
|||||||
loadBalancer: {
|
loadBalancer: {
|
||||||
servers: [
|
servers: [
|
||||||
{
|
{
|
||||||
url: `http://${maintenanceHost}:${maintenancePort}`
|
url: browserGatewayUiUrl
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
passHostHeader: true
|
passHostHeader: true
|
||||||
|
|||||||
@@ -277,6 +277,8 @@ hybridRouter.get(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const browserGatewayUiUrl = config.getRawConfig().app.dashboard_url; // points to the dashboard to serve from there
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const traefikConfig = await getTraefikConfig(
|
const traefikConfig = await getTraefikConfig(
|
||||||
remoteExitNode.exitNodeId,
|
remoteExitNode.exitNodeId,
|
||||||
@@ -285,7 +287,7 @@ hybridRouter.get(
|
|||||||
false, // Dont include login pages,
|
false, // Dont include login pages,
|
||||||
true, // allow raw resources
|
true, // allow raw resources
|
||||||
false, // dont generate maintenance page
|
false, // dont generate maintenance page
|
||||||
false // dont generate browser gateway targets
|
browserGatewayUiUrl // generate browser gateway targets
|
||||||
);
|
);
|
||||||
|
|
||||||
return response(res, {
|
return response(res, {
|
||||||
|
|||||||
@@ -17,13 +17,18 @@ export async function traefikConfigProvider(
|
|||||||
// Get the current exit node name from config
|
// Get the current exit node name from config
|
||||||
const currentExitNodeId = await getCurrentExitNodeId();
|
const currentExitNodeId = await getCurrentExitNodeId();
|
||||||
|
|
||||||
|
const maintenancePort = config.getRawConfig().server.next_port;
|
||||||
|
const maintenanceHost = config.getRawConfig().server.internal_hostname;
|
||||||
|
const browserGatewayUiUrl = `http://${maintenanceHost}:${maintenancePort}`;
|
||||||
|
|
||||||
const traefikConfig = await getTraefikConfig(
|
const traefikConfig = await getTraefikConfig(
|
||||||
currentExitNodeId,
|
currentExitNodeId,
|
||||||
config.getRawConfig().traefik.site_types,
|
config.getRawConfig().traefik.site_types,
|
||||||
build == "oss", // filter out the namespace domains in open source
|
build == "oss", // filter out the namespace domains in open source
|
||||||
build != "oss", // generate the login pages on the cloud and and enterprise,
|
build != "oss", // generate the login pages on the cloud and and enterprise,
|
||||||
config.getRawConfig().traefik.allow_raw_resources,
|
config.getRawConfig().traefik.allow_raw_resources,
|
||||||
build != "oss" // generate browser gateway resources on cloud and enterprise
|
build != "oss", // generate maintenance page on cloud and enterprise
|
||||||
|
browserGatewayUiUrl
|
||||||
);
|
);
|
||||||
|
|
||||||
if (traefikConfig?.http?.middlewares) {
|
if (traefikConfig?.http?.middlewares) {
|
||||||
|
|||||||
Reference in New Issue
Block a user