0

I'm trying to proxy_pass_header Connection; to my node.js server. But my response header getting overwritten Connection : keep-alive Even when I explicitly changed the Connection : close.

What I'm doing wrong?

Left Over
  • 241
  • 3
  • 16

1 Answers1

1

That is because you have nginx in front and that will respond based on its own settings. You should use below directive in your nginx conf if you don't want to keep connection alive

keepalive_timeout 0;
Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265
  • It solves the problem but right now I'm facing another. keepalive_timeout 0; dosen't let node response header to be Connection: keep-alive. It's always close. – Left Over Aug 15 '17 at 13:57
  • See if this helps https://stackoverflow.com/questions/10395807/nginx-close-upstream-connection-after-request – Tarun Lalwani Aug 15 '17 at 13:59
  • What I really want is to control the Connection from node.js based on some logic. Is it possible? – Left Over Aug 15 '17 at 13:59
  • Try this `add_header Connection $upstream_http_connection;`. This will try and response with your upstream connection response header – Tarun Lalwani Aug 15 '17 at 14:04
  • Also see if this is needed https://stackoverflow.com/questions/10395807/nginx-close-upstream-connection-after-request – Tarun Lalwani Aug 15 '17 at 14:09