Make reverse proxy mod establish only close connections, no keep-alive

This commit is contained in:
svrjs 2023-08-03 01:11:55 +02:00
parent bb938f3cb0
commit 908ad23ef5
2 changed files with 7 additions and 2 deletions

View file

@ -51,20 +51,25 @@ Mod.prototype.callback = function callback(req, res, serverconsole, responseEnd,
delete hdrs[":scheme"];
delete hdrs[":authority"];
delete hdrs[":path"];
delete hdrs["keep-alive"];
hdrs["connection"] = "close";
var options = {
hostname: (secureHostname && req.socket.encrypted) ? secureHostname : hostname,
port: (secureHostname && req.socket.encrypted) ? securePort : port,
path: req.url,
method: req.method,
headers: hdrs,
joinDuplicateHeaders: true,
rejectUnauthorized: false
};
var proxy = ((secureHostname && req.socket.encrypted) ? https : http).request(options, function(sres) {
serverconsole.resmessage("Connected to back-end!");
delete sres.headers["connection"];
delete sres.headers["Connection"];
delete sres.headers["Transfer-Encoding"];
delete sres.headers["transfer-encoding"];
delete sres.headers["Transfer-Encoding"];
delete sres.headers["keep-alive"];
delete sres.headers["Keep-Alive"];
res.writeHead(sres.statusCode, sres.headers);
sres.pipe(res, {
end: true

2
mod.info Executable file → Normal file
View file

@ -1,4 +1,4 @@
{
"name": "Reverse proxy mod for SVR.JS 3.x",
"version": "1.0.2"
"version": "1.0.3"
}