keepalive_timeout, proxy_send_timeout, and proxy_read_timeout ignored
dgobaud
nginx-forum at nginx.us
Mon Jul 13 17:40:32 UTC 2015
Hi, I'm using AWS Beanstalk with nginx in front of a Puma server serving
Ruby on Rails. I have one URL that is for an EventSource so it is kept alive
and data is streamed out. I was running into this problem
http://forum.nginx.org/read.php?2,237386,237386 where when the client closes
the browser but nginx keeps the connection alive forever so I tried having
nginx automatically close the connection after 5 seconds. I set
keepalive_timeout, proxy_send_timeout, and proxy_read_timeout all to 5
seconds but all were ignored. The connection remained open until nginx was
restarted.
# nginx config
upstream my_app {
server unix:///var/run/puma/my_app.sock;
}
server {
listen 80;
server_name _ localhost; # need to listen to localhost for worker tier
if ($http_x_forwarded_proto = "http") { return 301
https://$host$request_uri; }
location /dashboard_stream {
proxy_pass http://my_app; # match the name of upstream directive which
is defined above
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
proxy_cache off;
proxy_http_version 1.1;
proxy_set_header Connection '';
chunked_transfer_encoding off;
keepalive_timeout 5s;
proxy_send_timeout 5s;
proxy_read_timeout 5s;
}
}
# nginx version
nginx version: nginx/1.6.2
# AWS linux version
NAME="Amazon Linux AMI"
VERSION="2015.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2015.03"
PRETTY_NAME="Amazon Linux AMI 2015.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2015.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
Amazon Linux AMI release 2015.03
# kernel version
Linux ip-172-31-12-138 3.14.42-31.38.amzn1.x86_64 #1 SMP Wed May 13 20:33:05
UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,260257,260257#msg-260257
More information about the nginx
mailing list