UDP Load balancing

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

UDP Load balancing

vergil
Hi, I am testing nginx as a reverse proxy/load balancer for UDP. I have
configured the upstream servers, and it is working fine, except one issue
that is driving me crazy.

It seems that nginx does not keep the udp source ports between requests. It
changes the source port on every request. So I can't use it to load balance
udp protocols that needs several packets (for example, wireguard).

I am using  version 1.14.0 on Ubuntu and this is my config file:

stream {
  upstream udp_backend {
    hash $remote_addr;
    server 10.0.0.3:5180;
    server 10.0.0.4:5180;
  }
  server {
      listen 5180 udp;
      proxy_pass udp_backend;
      proxy_bind 10.0.0.2:5181;
  }
}

Is there any parameter that allows me to preserve udp ports?
Thanks.

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

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: UDP Load balancing

Roman Arutyunyan
Hi,

On Tue, Jan 28, 2020 at 08:52:53AM -0500, arigatox wrote:
> Hi, I am testing nginx as a reverse proxy/load balancer for UDP. I have
> configured the upstream servers, and it is working fine, except one issue
> that is driving me crazy.
>
> It seems that nginx does not keep the udp source ports between requests. It
> changes the source port on every request. So I can't use it to load balance
> udp protocols that needs several packets (for example, wireguard).
>
> I am using  version 1.14.0 on Ubuntu and this is my config file:

Your nginx is too old.  UDP session persistence has been introduced in mainline
version 1.15.0 and is available in stable version 1.16.0.

> stream {
>   upstream udp_backend {
>     hash $remote_addr;
>     server 10.0.0.3:5180;
>     server 10.0.0.4:5180;
>   }
>   server {
>       listen 5180 udp;
>       proxy_pass udp_backend;
>       proxy_bind 10.0.0.2:5181;
>   }
> }
>
> Is there any parameter that allows me to preserve udp ports?
> Thanks.
>
> Posted at Nginx Forum: https://forum.nginx.org/read.php?2,286837,286837#msg-286837
>
> _______________________________________________
> nginx mailing list
> [hidden email]
> http://mailman.nginx.org/mailman/listinfo/nginx

--
Roman Arutyunyan
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: UDP Load balancing

vergil
Thanks Roman, I will try a newer version and let you know

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

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: UDP Load balancing - [Solved]

vergil
Excellent! I upgraded to 1.16.1 and udp load balancing is working as
expected.
Thank you again Roman.

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

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: UDP Load balancing - [Solved]

vergil
Hello @arigatox,

do you mind share with me, how to LB UDP protocol like wireguard?

My nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

stream {

upstream syslog_udp {
        server x.x.x.x:51820;
        server x.x.x.x:51820;
}

server {
        listen 51820 udp;
        proxy_pass syslog_udp;
        proxy_responses 0;
}


}

        worker_rlimit_nofile 1000000;

events {

        worker_connections 20000;

}


my nginx :
nginx version: nginx/1.16.1

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

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: UDP Load balancing - [Solved]

Andrei


On Wed, Apr 22, 2020 at 4:22 AM deprito <[hidden email]> wrote:
Hello @arigatox,

do you mind share with me, how to LB UDP protocol like wireguard?

My nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

stream {

upstream syslog_udp {
        server x.x.x.x:51820;
        server x.x.x.x:51820;
}

server {
        listen 51820 udp;
        proxy_pass syslog_udp;
        proxy_responses 0;
}


}


This is hilarious:
 
        worker_rlimit_nofile 1000000;

What makes you think your box can handle that many open files? :D
 

events {

        worker_connections 20000;

}


my nginx :
nginx version: nginx/1.16.1

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

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx