From 9702d246dbaaa18fe4e9b16561ef030e6e0346fd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 05:30:06 +0000 Subject: [PATCH] Fix Apache reverse proxy 502 error by configuring HTTP server timeouts Set keepAliveTimeout to 65 seconds (longer than Apache's default 5s KeepAliveTimeout), headersTimeout to 66 seconds, and requestTimeout to 120 seconds. This prevents "Connection reset by peer" errors when using Apache2 as a reverse proxy. Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> --- back/services/http.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/back/services/http.ts b/back/services/http.ts index 5391c842..a00e6742 100644 --- a/back/services/http.ts +++ b/back/services/http.ts @@ -19,6 +19,17 @@ export class HttpServerService { resolve(this.server); }); + // Configure server timeouts for better compatibility with reverse proxies + // Set keepAliveTimeout to 65 seconds (longer than Apache's default KeepAliveTimeout of 5s) + // This prevents "Connection reset by peer" errors with Apache reverse proxy + if (this.server) { + this.server.keepAliveTimeout = 65000; // 65 seconds + // headersTimeout should be slightly longer than keepAliveTimeout + this.server.headersTimeout = 66000; // 66 seconds + // Set a reasonable request timeout + this.server.requestTimeout = 120000; // 120 seconds + } + this.server?.on('error', (err: Error) => { Logger.error('Failed to start HTTP service:', err); reject(err);