fix: Use container-internal port 80 in gateway Caddyfile
The Caddyfile was using the host port (e.g., 9100) as the Caddy listen address, but Docker maps host:9100 → container:80. Caddy inside the container was listening on 9100 while Docker only forwarded to port 80, causing all health checks to fail with "connection reset by peer".
This commit is contained in:
@@ -164,7 +164,7 @@ describe('generateGatewayCaddyfile', () => {
|
||||
|
||||
const caddyfile = generateGatewayCaddyfile(previews, 9100);
|
||||
expect(caddyfile).toContain('auto_https off');
|
||||
expect(caddyfile).toContain('localhost:9100 {');
|
||||
expect(caddyfile).toContain(':80 {');
|
||||
expect(caddyfile).toContain('handle_path /abc123/*');
|
||||
expect(caddyfile).toContain('reverse_proxy cw-preview-abc123-app:3000');
|
||||
});
|
||||
@@ -193,7 +193,7 @@ describe('generateGatewayCaddyfile', () => {
|
||||
]);
|
||||
|
||||
const caddyfile = generateGatewayCaddyfile(previews, 9100);
|
||||
expect(caddyfile).toContain('localhost:9100 {');
|
||||
expect(caddyfile).toContain(':80 {');
|
||||
expect(caddyfile).toContain('handle_path /abc/*');
|
||||
expect(caddyfile).toContain('handle_path /xyz/*');
|
||||
expect(caddyfile).toContain('reverse_proxy cw-preview-abc-app:3000');
|
||||
|
||||
@@ -201,14 +201,16 @@ export class GatewayManager {
|
||||
*/
|
||||
export function generateGatewayCaddyfile(
|
||||
previews: Map<string, GatewayRoute[]>,
|
||||
port: number,
|
||||
_port: number,
|
||||
): string {
|
||||
// Caddy runs inside a container where Docker maps host:${port} → container:80.
|
||||
// The Caddyfile must listen on the container-internal port (80), not the host port.
|
||||
const lines: string[] = [
|
||||
'{',
|
||||
' auto_https off',
|
||||
'}',
|
||||
'',
|
||||
`localhost:${port} {`,
|
||||
`:80 {`,
|
||||
];
|
||||
|
||||
for (const [previewId, routes] of previews) {
|
||||
|
||||
Reference in New Issue
Block a user