Retaining upstream server

nov1ce nginx-forum at forum.nginx.org
Wed Jun 20 07:16:40 UTC 2018


Hello,

1.14.0-1 running on Debian Stretch:

# dpkg -l | grep nginx
ii  nginx                          1.14.0-1~stretch               amd64     
  high performance web server

I'm trying to load balance between two VMware View Connection servers
(10.7.18.121 and 10.7.18.122) listening on 443/tcp, 4172/tcp and 4172/udp. 
The way the application works is: first, the connecting client hits 443/tcp
where authentication takes place, then the client gets connected to 4172/tcp
(or 4172/udp).

I have no problems when the connection is handled by the same upstream
server, such as: remote_client > nginx_vip > 10.7.18.121:443 >
10.7.18.121:4172 or remote_client > nginx_vip > 10.7.18.122:443 >
10.7.18.122:4172. However, I get application errors if 443/tcp is handled by
one server and 4172/tcp/udp by another.

Therefore, I was wondering whether it'd be possible to configure Nginx in a
such way that the upstream server is retained through the whole session? I
mean, if a client gets served by 10.7.18.121:443 Nginx will use the same
upstream to deliver 4172/tcp/udp?

I can probably switch to active-backup model, but I was hoping to benefit
from the load distribution.

Many thanks.

stream {

   log_format  basic   '$time_iso8601 $remote_addr '
                        '$protocol $status $bytes_sent $bytes_received '
                        '$session_time $upstream_addr '
                        '"$upstream_bytes_sent" "$upstream_bytes_received"
"$upstream_connect_time"';
   access_log  /var/log/nginx/stream_access.log basic;

   upstream test_horizon_4172_tcp {
      hash $remote_addr consistent;
      server 10.7.18.121:4172;
      server 10.7.18.122:4172;
    }

   upstream test_horizon_4172_udp {
      hash $remote_addr consistent;
      server 10.7.18.121:4172;
      server 10.7.18.122:4172;
    }

   upstream test_horizon_https {
      hash $remote_addr consistent;
      server 10.7.18.121:443;
      server 10.7.18.122:443;
    }

   server {
      listen 4172;
      proxy_pass test_horizon_4172_tcp;
   }

   server {
      listen 4172 udp;
      proxy_pass test_horizon_4172_udp;
   }

   server {
      listen 443;
      proxy_pass test_horizon_https;
   }

}

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,280183,280183#msg-280183



More information about the nginx mailing list