Lua Nginx and TCP

539 views
Skip to first unread message

Simon Hørup Eskildsen

unread,
Apr 28, 2015, 3:20:58 PM4/28/15
to openre...@googlegroups.com
Hello everyone, with the recent addition to the open source Nginx of TCP support (http://hg.nginx.org/nginx/rev/61d7ae76647d) I'm curious whether anyone has been working on getting some of Openresty to play well with it, e.g. the community module for health checks which is not part of the open source distribution. Is support for it planned in lua-nginx?

Cheers

in...@ecsystems.nl

unread,
Apr 28, 2015, 5:09:11 PM4/28/15
to openre...@googlegroups.com
Hmm, following: http://nginx.com/resources/admin-guide/tcp-load-balancing/
I get a nginx: [emerg] "stream" directive is not allowed here
eventhough its with the http context like upstreams are, anyone with a good example?

Robert Paprocki

unread,
Apr 28, 2015, 6:18:24 PM4/28/15
to openre...@googlegroups.com
It needs to be at the -same- level as the http {} block, not -within- the http {} block.

worker_processes  4;

events {
    worker_connections  8192;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    }

    stream {
        upstream stream_backend {
            server 192.168.222.22:810 weight=5;
            server 192.168.222.17:810 weight=5;
    }

    server {
        listen     12345;
        proxy_pass stream_backend;
    }

}

--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert Paprocki

unread,
Apr 28, 2015, 6:28:45 PM4/28/15
to openre...@googlegroups.com
Whoops, sorry, mistyped (and untested, but just going off the documentation). Try:

in...@ecsystems.nl

unread,
Apr 29, 2015, 3:16:56 AM4/29/15
to openre...@googlegroups.com, rob...@cryptobells.com
Stop nicking my forum posts :) :)
like I said there http is not stream so this makes sense,

http { http-things; }
stream { stream-things; }

It just feels unnatural to configure something outside the http block.

Vladislav Manchev

unread,
Apr 29, 2015, 3:45:08 AM4/29/15
to openre...@googlegroups.com, rob...@cryptobells.com
Shouldn't feel unnatural, consider TCP/UDP servers support planned here (already started prototyping this a while ago): https://github.com/openresty/lua-nginx-module#todo

Doesn't make sense to have this under http block.


Best,
Vladislav

in...@ecsystems.nl

unread,
Apr 29, 2015, 5:46:09 AM4/29/15
to openre...@googlegroups.com, rob...@cryptobells.com


On Wednesday, April 29, 2015 at 9:45:08 AM UTC+2, Vladislav Manchev wrote:
Shouldn't feel unnatural, consider TCP/UDP servers support planned here (already started prototyping this a while ago): https://github.com/openresty/lua-nginx-module#todo

Doesn't make sense to have this under http block.



It doesn't no, but after x many years people are used to doing things inside a block, it takes a bit of a mind switch to realize this falls outside the normal configuration thinking space. Documentation wise there should have been more information about this other then just import dozens of changesets and expect everyone to understand how this suppose to work. Even the existing documentation is a maze at best.
 

Yichun Zhang (agentzh)

unread,
May 7, 2015, 7:07:10 AM5/7/15
to openresty-en
Hello!

On Wed, Apr 29, 2015 at 3:20 AM, Simon Hørup Eskildsen wrote:
> Hello everyone, with the recent addition to the open source Nginx of TCP
> support (http://hg.nginx.org/nginx/rev/61d7ae76647d)

Yeah for the new stream world! It opens the door for general
TCP/stream server programming.

> I'm curious whether
> anyone has been working on getting some of Openresty to play well with it,
> e.g. the community module for health checks which is not part of the open
> source distribution. Is support for it planned in lua-nginx?

My hunch is that we can create an ngx_stream_lua_module outside of our
existing ngx_http_lua_module. This paves a way for downstream TCP
support of OpenResty. This TODO item of ngx_lua can finally be
materialized :)

The existing ngx_http_lua_module can only be used in the context of
the http {} configuration block. For stream {} blocks, we need
ngx_stream_lua_module :)

I'm curious whether the nginx team is also planning a datagram {}
configuration block for general UDP/datagram downstream
communications. Anyone knows?

I'll need a closer look at this new 1.9.x feature when I'm back from
my long vacation. (Yeah, I'm still on vacation in China *grin*)

Best regards,
-agentzh

Simon Hørup Eskildsen

unread,
May 7, 2015, 7:36:23 AM5/7/15
to openresty-en
Looking forward to an update on that agenzh! Enjoy your vacation :-) 

Abdul Hakeem

unread,
Jun 12, 2015, 8:39:53 PM6/12/15
to openre...@googlegroups.com

Hello,

Any updates on the proposed implementation of UDP server and TCP stream server  ?

Best regards,

Abdul Hakeem

Yichun Zhang (agentzh)

unread,
Jun 12, 2015, 10:41:41 PM6/12/15
to openresty-en
Hello!

On Sat, Jun 13, 2015 at 8:39 AM, Abdul Hakeem wrote:
> Any updates on the proposed implementation of UDP server and TCP stream
> server ?
>

Not yet. My first priority at the moment is rolling out OpenResty
1.7.10.2 (and later 1.9.x.x).

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages