I am setting up a nginx webserver with php-fpm and (d)dos deflate to ban attacks.

Now currently there is no traffic to my server at all, as i'm testing things.

With this command i can see who is connected to my server, and how many connections they have open:

netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

During testing I noticed that when I would load a test script which is basicly <?php phpinfo(); ?> it would start 3 connections. I guess 1 for the HTML an 2 for the 2 images on that page. All is fine so far...

But I noticed it took well over a minute before those 3 connections where closed. I kept running the above netstat command to see if those 3 external connections would close.

My nginx.conf has a keep alive timeout of 4.

  keepalive_timeout       4;

The connection was made via a default setup Chrome browser.

How come those connections stayed open so long, and is this normal? Also, is there a way I can close them sooner?

link|improve this question

73% accept rate
Are you asking the timeout value for TCP? – Mughil Jan 6 at 11:49
Yes I think that must be it. Where is that defined? – FunkyChicken Jan 6 at 12:02
Are you sure your keepalive_timeout configuration is applying correctly? "Well over a minute" sounds like the default of 75 seconds. – Shane Madden Jan 6 at 18:05
feedback

1 Answer

up vote 1 down vote accepted

You can increase or decrease timeouts on TCP sockets using the file tcp_keepalive_time found on the directory /proc/sys/net/ipv4/ .

The default timeout value is 7200 (2 hours).

For example, to change into 1200 seconds issue the command as below:

#echo 1200 > /proc/sys/net/ipv4/tcp_keepalive_time
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.