I'm trying to disable the keep-alive
setting in a very simple express
app. I tried the answer from someone doing the same in an older version:
var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.set('Connection', 'close'); // attempting to override default (keep-alive)
res.set('Proof', 'close'); // just to show that this should modify the header value
res.send('hello');
});
var server = app.listen(3000, function() {
console.log('Listening on port %d', server.address().port);
});
However, Connection
is still set to keep-alive
:
$ curl -D - http://my-test-site.com
HTTP/1.1 200 OK
Server: nginx/1.4.7
Date: Sun, 11 May 2014 08:07:51 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 5
Connection: keep-alive
X-Powered-By: Express
Proof: close
ETag: "907060870"
hello%
How can I change keep-alive
to close
?
node 0.10.8
express 4.1.1
It works fine for me. I test it localhost the same version.
$ curl -D - 127.0.0.1:3000
HTTP/1.1 200 OK
X-Powered-By: Express
Connection: close
Proof: close
Content-Type: text/html; charset=utf-8
Content-Length: 5
ETag: "907060870"
Date: Sun, 11 May 2014 08:52:32 GMT
hello%
I see that you may use nginx
to proxy. Like below:
client--nginx proxy--real server
I guess that you should disable keep-alive
in nginx config file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With