fix: 配置公共边缘集群 DNS

This commit is contained in:
Codex
2026-07-16 10:15:27 +02:00
parent aa1a17e8a1
commit db2b39e846
2 changed files with 7 additions and 1 deletions
+2
View File
@@ -34,6 +34,8 @@ targets:
caddyfilePath: /opt/unidesk/pikaoa-edge/Caddyfile
dataDir: /var/lib/unidesk/pikaoa-edge/caddy-data
configDir: /var/lib/unidesk/pikaoa-edge/caddy-config
dnsServers:
- 10.43.0.10
responseHeaderTimeoutSeconds: 60
sites:
- id: pikaoa-development
+5 -1
View File
@@ -60,6 +60,7 @@ export interface PublicEdgeTarget {
caddyfilePath: string;
dataDir: string;
configDir: string;
dnsServers: string[];
responseHeaderTimeoutSeconds: number;
};
siteReferences: SiteReference[];
@@ -189,6 +190,7 @@ function readTarget(root: Record<string, unknown>, requestedTargetId: string | n
caddyfilePath: absolutePath(runtime.caddyfilePath, `targets.${targetId}.runtime.caddyfilePath`),
dataDir: absolutePath(runtime.dataDir, `targets.${targetId}.runtime.dataDir`),
configDir: absolutePath(runtime.configDir, `targets.${targetId}.runtime.configDir`),
dnsServers: array(runtime.dnsServers, `targets.${targetId}.runtime.dnsServers`).map((value, index) => ipv4(value, `targets.${targetId}.runtime.dnsServers[${index}]`)),
responseHeaderTimeoutSeconds: positiveInteger(runtime.responseHeaderTimeoutSeconds, `targets.${targetId}.runtime.responseHeaderTimeoutSeconds`),
},
siteReferences: sites.map((value, index) => {
@@ -360,7 +362,8 @@ export function renderPublicEdgeArtifacts(target: PublicEdgeTarget, sites: Resol
const protocols = target.listener.protocols.join(" ");
const global = `\{\n\tservers \{\n\t\tprotocols ${protocols}\n\t\}\n\}\n`;
const blocks = sites.map((site) => `${site.hostname} \{\n\treverse_proxy ${site.upstream} \{\n\t\ttransport http \{\n\t\t\tresponse_header_timeout ${target.runtime.responseHeaderTimeoutSeconds}s${site.upstreamTlsServerName === undefined ? "" : `\n\t\t\ttls_server_name ${site.upstreamTlsServerName}`}\n\t\t\}\n\t\}\n\}\n`).join("\n");
const compose = `services:\n caddy:\n image: ${target.runtime.image}\n container_name: ${target.runtime.containerName}\n network_mode: host\n restart: unless-stopped\n volumes:\n - ${target.runtime.caddyfilePath}:/etc/caddy/Caddyfile:ro\n - ${target.runtime.dataDir}:/data\n - ${target.runtime.configDir}:/config\n`;
const dnsServers = target.runtime.dnsServers.map((server) => ` - ${server}`).join("\n");
const compose = `services:\n caddy:\n image: ${target.runtime.image}\n container_name: ${target.runtime.containerName}\n network_mode: host\n restart: unless-stopped\n dns:\n${dnsServers}\n volumes:\n - ${target.runtime.caddyfilePath}:/etc/caddy/Caddyfile:ro\n - ${target.runtime.dataDir}:/data\n - ${target.runtime.configDir}:/config\n`;
return { caddyfile: `${global}\n${blocks}`, compose };
}
@@ -537,6 +540,7 @@ function targetSummary(target: PublicEdgeTarget): Record<string, unknown> {
composePath: target.runtime.composePath,
dataDir: target.runtime.dataDir,
configDir: target.runtime.configDir,
dnsServers: target.runtime.dnsServers,
};
}