Thursday, February 27, 2020

nginx reverse proxy(stream for udp), only server stream dead.

I use nginx for udp reverse proxy server. like

client ---(1)--> nginx ---(2)--> server

When i re-install my server, udp proxy dies.

In most cases, the client stream(1) and server stream(2) die together, nginx try reconnect reverse proxy.

However, sometimes client stream(1) is alive, only the server stream(2) dies, then nginx doesn't try reconnect reverse proxy.

So server can get message from client, but cannot send to message to client.

The result of tcpdump like,

client > nginx:port

nginx:port > server

server > nginx:port

nginx:port > client

...

(2) only dies

client > nginx:port

nginx:port > server

server > nginx:port

...

No 'nginx:port > client'.

My error log when (2) only dies,

2020/02/27 17:41:13 [info] 34906#0: *647 udp client 192.168.0.184:49153 connected to 0.0.0.0:11325 2020/02/27 17:41:13 [info] 34906#0: *647 udp proxy 127.0.0.1:51513 connected to 127.0.0.1:31114 2020/02/27 17:41:13 [error] 34906#0: *647 recv() failed (61: Connection refused) while proxying and reading from upstream, udp client: 192.168.0.184, server: 0.0.0.0:11325, upstream: "127.0.0.1:31114", bytes from/to client:43/0, bytes from/to upstream:0/43 -- No reconnect -- 

Error log when (1) (2) die together,

2020/02/27 17:41:25 [info] 34906#0: *651 udp client 192.168.0.184:49153 connected to 0.0.0.0:11325 2020/02/27 17:41:25 [info] 34906#0: *651 udp proxy 127.0.0.1:60319 connected to 127.0.0.1:31114 2020/02/27 17:41:25 [error] 34906#0: *651 recv() failed (61: Connection refused) while proxying and reading from upstream, udp client: 192.168.0.184, server: 0.0.0.0:11325, upstream: "127.0.0.1:31114", bytes from/to client:43/0, bytes from/to upstream:0/43 2020/02/27 17:41:29 [error] 34906#0: *651 sendmsg() failed (61: Connection refused) while proxying and sending to upstream, udp client: 192.168.0.184, server: 0.0.0.0:11325, upstream: "127.0.0.1:31114", bytes from/to client:129/0, bytes from/to upstream:0/86 2020/02/27 17:41:31 [info] 34906#0: *653 udp client 192.168.0.184:49153 connected to 0.0.0.0:11325 2020/02/27 17:41:31 [info] 34906#0: *653 udp proxy 127.0.0.1:58601 connected to 127.0.0.1:31114 

How can I change my configuration that nginx force reconnect proxy when only server stream closed?



No comments:

Post a Comment