-
Notifications
You must be signed in to change notification settings - Fork 235
Description
I am running into an issue where express-http-proxy appears to close connection with the client and send 504 status.
In our usecase, a client request is sent down different nodes as shown below. The Reverse Proxy server is responsible for enforcing authn/authz policies before proxying request to the UI proxy app. This reverse proxy server is injecting Transfer-Encoding header with value as chunked for all requests, irrespective of whether there is any actual payload in the request i.e. even the GET requests without any request body have this header.
Client (Browser) --> Load Balancer (Reverse Proxy) --> UI Proxy app (ExpressJs) --> Backend App
Problem is the the UI Proxy app that is using express-http-proxy appears to close connection with the ReveseProxy server immediately.
In the response received at RP, we can see the following headers.
X-Powered-By: Express
X-Timeout-Reason: express-http-proxy reset the request.
Content-Type: text/plain
Date: Tue, 10 Dec 2024 19:15:36 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked
Follow steps below to reproduce this issue.
- Create app.js with the following code.
const proxy = require('express-http-proxy');
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.use('/proxy', proxy('https://example.com'));
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
- Send request using following command.
curl --location 'http://localhost:3000/proxy' --header 'Transfer-Encoding: chunked'