NGINX Open Source TCP Load Balancing - service discovery

Matthew Ceroni matthewceroni at
Mon Oct 17 21:44:00 UTC 2016

Testing out the options provided in the above link. Specifically the
"Setting the Domain Name in a Variable". The example given is L7 load

I have a need for L4 using upstream, yet I am not able to get this method
to work (if it even does). The Note seems to indicate that it does by
stating that this method is available in 1.11.3 of the Open source version.

The issue is around where to set the variable. I have tried setting it in
the upstream block but that errors saying set is not valid in this context.
Tried setting it in the stream context, same error.

I have also tried this on both Plus and open source and get the same errors
on both.

Any insight would be helpful. Thanks


# TCP/UDP proxy and load balancing block
stream {
    proxy_protocol on;

    resolver valid=10s;

    # Example configuration for TCP load balancing

    upstream stream_backend {
        zone tcp_servers 64k;
        server backend_servers:25 max_fails=3;

    server {
        listen 25;
        status_zone tcp_server;
        proxy_pass stream_backend;

So basically I need to replace server backend_servers with server
$backend_servers but need to set that variable somewhere.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list