# Building nginx with TCP\_FASTOPEN enabled

**URL:** <https://www.ruby-forum.com/t/building-nginx-with-tcp-fastopen-enabled/231467>\
**Category:** NGINX\
**Created:** [August 9, 2014, 8:19pm UTC](https://www.ruby-forum.com/t/building-nginx-with-tcp-fastopen-enabled/231467 "2014-08-09T20:19:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [August 9, 2014, 8:19pm UTC](https://www.ruby-forum.com/t/building-nginx-with-tcp-fastopen-enabled/231467/1 "2014-08-09T20:19:58Z")

</div>

Hello,

I’ve tried to use “fastopen” in the listen directive but nginx gave me  
an  
error that the option is unkown.

I’m using nginx 1.7.4 on Debian Wheezy 3.14.13 kernel.

I’ve compiled nginx myself.  
When I run the configure command, I get:  
“checking for TCP\_FASTOPEN … not found”

‘cat /proc/sys/net/ipv4/tcp\_fastopen’ gives me “3” - I also tried it  
with  
the value “2”.

Why does my system not support TCP fastopen? My kernel is recent  
enough…

thank you,  
Can

Posted at Nginx Forum:

> **[Building nginx with TCP\_FASTOPEN enabled](https://forum.nginx.org/read.php?2,252447,252447#msg-252447)**
>
> Hello, I've tried to use "fastopen" in the listen directive but nginx gave me an error that the option is unkown. I'm using nginx 1.7.4 on Debian Wheezy 3.14.13 kernel. I've compiled nginx myself. When I run the configure command, I get:

---

<div class="post-metadata">

**Author:** ![mastercan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@mastercan](https://www.ruby-forum.com/u/mastercan)\
**Post date:** [August 10, 2014, 2:33am UTC](https://www.ruby-forum.com/t/building-nginx-with-tcp-fastopen-enabled/231467/2 "2014-08-10T02:33:45Z")

</div>

Hello!

On Sat, Aug 09, 2014 at 02:19:32PM -0400, mastercan wrote:

> ‘cat /proc/sys/net/ipv4/tcp\_fastopen’ gives me “3” - I also tried it with  
> the value “2”.
> 
> Why does my system not support TCP fastopen? My kernel is recent enough…

Try looking into objs/autoconf.err, it has details about configure  
test failures. Most likely, the TCP\_FASTOPEN constant isn’t  
defined since your glibc isn’t recent enough, something like 2.18+  
is needed.

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![mastercan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@mastercan](https://www.ruby-forum.com/u/mastercan)\
**Post date:** [August 10, 2014, 1:59pm UTC](https://www.ruby-forum.com/t/building-nginx-with-tcp-fastopen-enabled/231467/3 "2014-08-10T13:59:43Z")

</div>

Maxim D. Wrote:

> Try looking into objs/autoconf.err, it has details about configure  
> test failures. Most likely, the TCP\_FASTOPEN constant isn’t  
> defined since your glibc isn’t recent enough, something like 2.18+  
> is needed.

Yes, you’re right. glibc was the problem. I tried to build an nginx deb  
package on a development machine with updated glibc libs and installed  
it on  
the production server.  
Unfortunately I get this error when trying to start nginx:  
“/lib/x86\_64-linux-gnu/libc.so.6: version `GLIBC\_2.14’ not found  
(required  
by /usr/sbin/nginx)”

So I guess I must upgrade glibc on the production server as well…which  
might break dependencies…

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,252447,252458#msg-252458](http://forum.nginx.org/read.php?2,252447,252458#msg-252458)

---

<div class="post-metadata">

**Author:** ![mastercan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@mastercan](https://www.ruby-forum.com/u/mastercan)\
**Post date:** [August 10, 2014, 2:49pm UTC](https://www.ruby-forum.com/t/building-nginx-with-tcp-fastopen-enabled/231467/4 "2014-08-10T14:49:42Z")

</div>

Lukas T. Wrote:

> Don’t upgrade libc because of this (it will mess your system up).
> 
> Just define it manually when compiling nginx by passing it to the  
> compiler:  
> -DTCP\_FASTOPEN=23

Which command accepts the -D flag?  
Where exactly do I set this option?

Thanks in advance

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,252447,252460#msg-252460](http://forum.nginx.org/read.php?2,252447,252460#msg-252460)

---

<div class="post-metadata">

**Author:** ![mastercan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@mastercan](https://www.ruby-forum.com/u/mastercan)\
**Post date:** [August 10, 2014, 2:25pm UTC](https://www.ruby-forum.com/t/building-nginx-with-tcp-fastopen-enabled/231467/5 "2014-08-10T14:25:18Z")

</div>

> Yes, you’re right. glibc was the problem. I tried to build an nginx deb  
> package on a development machine with updated glibc libs and installed it  
> on the production server.

Don’t upgrade libc because of this (it will mess your system up).

Just define it manually when compiling nginx by passing it to the  
compiler:  
-DTCP\_FASTOPEN=23

Regards,

Lukas

---

<div class="post-metadata">

**Author:** ![mastercan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@mastercan](https://www.ruby-forum.com/u/mastercan)\
**Post date:** [August 10, 2014, 2:54pm UTC](https://www.ruby-forum.com/t/building-nginx-with-tcp-fastopen-enabled/231467/6 "2014-08-10T14:54:27Z")

</div>

❦ 10 août 2014 07:59 -0400, “mastercan” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) :

> “/lib/x86\_64-linux-gnu/libc.so.6: version `GLIBC\_2.14’ not found (required  
> by /usr/sbin/nginx)”
> 
> So I guess I must upgrade glibc on the production server as well…which  
> might break dependencies…

There is nothing in this feature that needs a recent glibc except the  
definition of TCP\_FASTOPEN constant. On the machine where you compile,  
you can just add the constant in /usr/include/linux/tcp.h and  
/usr/include/netinet/tcp.h. The resulting binary will work on another  
machine without this modification.

## nginx should just define this symbol when not available. The remaining of the code is already detecting at runtime if this feature is available or not.

Localise input and output in subroutines.  
- The Elements of Programming Style (Kernighan & Plauger)

---

<div class="post-metadata">

**Author:** ![mastercan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@mastercan](https://www.ruby-forum.com/u/mastercan)\
**Post date:** [August 10, 2014, 3:01pm UTC](https://www.ruby-forum.com/t/building-nginx-with-tcp-fastopen-enabled/231467/7 "2014-08-10T15:01:01Z")

</div>

Lukas T. Wrote:

> Don’t upgrade libc because of this (it will mess your system up).
> 
> Just define it manually when compiling nginx by passing it to the  
> compiler:  
> -DTCP\_FASTOPEN=23

Thank you! This seems to define the constant. I simply added  
–with-cc-opt=“-DTCP\_FASTOPEN=23”  
to my configure command.

I think this will work (I’m compiling it right now…)

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,252447,252462#msg-252462](http://forum.nginx.org/read.php?2,252447,252462#msg-252462)
