feat: add hwlab opencode public proxy config

This commit is contained in:
Codex
2026-06-29 16:28:59 +00:00
parent 9a84e2d258
commit 58eec6ec0d
4 changed files with 118 additions and 23 deletions
+12 -1
View File
@@ -455,6 +455,7 @@ export function publicExposureSummary(exposure: HwlabRuntimePublicExposureSpec):
tokenKey: exposure.tokenKey,
webProxy: exposure.webProxy,
apiProxy: exposure.apiProxy,
extraProxies: exposure.extraProxies,
},
caddy: {
route: exposure.caddyRoute,
@@ -982,7 +983,7 @@ export function publicExposureCaddyScript(options: NodePublicExposureOptions, ex
export function publicExposureCaddyBlock(exposure: HwlabRuntimePublicExposureSpec): string {
const tlsLines = exposure.caddyTls === "internal" ? " tls internal\n" : "";
return `${exposure.hostname} {
const mainBlock = `${exposure.hostname} {
${tlsLines} @api path /health* /auth* /v1* /json-rpc* /openapi* /docs* /swagger*
reverse_proxy @api 127.0.0.1:${exposure.apiProxy.remotePort} {
transport http {
@@ -995,6 +996,16 @@ ${tlsLines} @api path /health* /auth* /v1* /json-rpc* /openapi* /docs* /swagg
}
}
}`;
const extraBlocks = exposure.extraProxies
.filter((proxy) => proxy.hostname !== undefined)
.map((proxy) => `${proxy.hostname} {
${tlsLines} reverse_proxy 127.0.0.1:${proxy.remotePort} {
transport http {
response_header_timeout ${exposure.responseHeaderTimeoutSeconds}s
}
}
}`);
return [mainBlock, ...extraBlocks].join("\n\n");
}
export function runTransScript(node: string, script: string, input: string, timeoutSeconds: number): CommandResult {