Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Are you asking the timeout value for TCP? –  Mughil Jan 6 '12 at 11:49
    
Yes I think that must be it. Where is that defined? –  Mr.Boon Jan 6 '12 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 '12 at 18:05

1 Answer 1

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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