NGINX负载平衡转弯服务器 [英] NGINX Load Balancing a Turn Server

查看:149
本文介绍了NGINX负载平衡转弯服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将负载均衡器放在Turn Server前面,以用于WebRTC.在下面的示例中,我将使用一转服务器,直到负载均衡器正常工作.转向服务器需要多个端口,包括一个UDP,如下所示:

I am attempting to put a Load Balancer in front of a Turn Server for use with WebRTC. I am using one turn server in my examples below until I get the load balancer working. The turn server requires multiple ports including one UDP as listed below:

  • TCP 80
  • TCP 443
  • TCP 3478
  • TCP 3479
  • UDP 3478

我尝试将Amazon Elastic Load Balancer(AW​​S ELB)放置在Turn Server的前面,但是它不支持UDP端口.因此,我现在在所有这些端口都打开的EC2实例上运行Ubuntu,并且已经安装了NGINX.

I have attempted to place an Amazon Elastic Load Balancer (AWS ELB) in front of the Turn Server, but it does not support the UDP port. So I am now running Ubuntu on an EC2 Instance with all these ports open and I have installed NGINX.

我已经编辑了/etc/nginx/nginx.conf文件,并在其中添加了"stream"部分,其中每个端口都有上游和服务器.但是,它似乎无法正确传递流量.

I've edited the /etc/nginx/nginx.conf file and added a "stream" section to it with both upstream and servers for each port. However, it does not appear to be passing the traffic correctly.

stream {
    # IPv4 Section
    upstream turn_tcp_3478 {
        server 192.168.1.100:3478;
    }
    upstream turn_tcp_3479 {
        server 192.168.1.100:3479;
    }
    upstream turn_upd_3478 {
        server 192.168.1.100:3478;
    }

    # IPv6 Section
    upstream turn_tcp_ipv6_3478{
        server [2600:myaw:esom:e:ipv6:addr:eswo:ooot]:3478;
    }
    upstream turn_tcp_ipv6_3479{
        server [2600:myaw:esom:e:ipv6:addr:eswo:ooot]:3479;
    }
    upstream turn_udp_ipv6_3478{
        server [2600:myaw:esom:e:ipv6:addr:eswo:ooot]:3478;
    }

    server {
        listen 3478; # tcp

        proxy_pass turn_tcp_3478;
    }
    server {
        listen 3479; # tcp
        proxy_pass turn_tcp_3479;
    }
    server {
        listen 3478 udp;
        proxy_pass turn_upd_3478;
    }
    server {
        listen [::]:3478;
        proxy_pass turn_tcp_ipv6_3478;
    }
    server {
        listen [::]:3479;
        proxy_pass turn_tcp_ipv6_3479;
    }
    server {
        listen [::]:3478 udp;
        proxy_pass turn_udp_ipv6_3478;
    }
}

我还在/etc/nginx/conf.d/load-balancer.conf中创建了一个自定义的负载均衡器配置文件,并将以下内容放入其中.

I have also created a custom load balancer configuration file at /etc/nginx/conf.d/load-balancer.conf and placed the following in it.

upstream turn_http {
    server 192.168.1.100;
}
upstream turn_https {
    server 192.168.1.100:443;
}

upstream turn_status {
    server 192.168.1.100:8080;
}

upstream turn_ipv6_http {
    server [2600:myaw:esom:e:ipv6:addr:eswo:ooot]:80;
}
upstream turn_ipv6_https {
    server [2600:myaw:esom:e:ipv6:addr:eswo:ooot]:443;
}

server {
    listen 80; 

    location / {
        proxy_pass http://turn_http;
    }
}

server {
    listen 443 ssl;

    server_name turn.awesomedomain.com;
    ssl_certificate /etc/ssl/private/nginx.ca-bundle;
    ssl_certificate_key /etc/ssl/private/nginx.key;

    location / {
        proxy_pass https://turn_https;
    }
}

server {
    listen 8080;

    location / {
        proxy_pass http://turn_status;
    }
}

server {
    listen [::]:80; 

    location / {
        proxy_pass http://turn_ipv6_http;
    }
}

server {
    listen [::]:443 ssl;

    server_name turn.awesomedomain.com;
    ssl_certificate /etc/ssl/private/nginx.ca-bundle;
    ssl_certificate_key /etc/ssl/private/nginx.key;

    location / {
        proxy_pass https://turn_ipv6_https;
    }
}

基于自定义的load-balancer.conf文件,http和https流量似乎工作正常.

The http and https traffic appear to be working fine based on the custom load-balancer.conf file.

我不确定为什么在ngnix.conf文件中配置的TCP/UDP端口无法正常工作.

I am unsure why the TCP/UDP Ports I have configured in the ngnix.conf file are not working as intended.

推荐答案

您对NGINX负载均衡器的配置很好.

Your configuration of the NGINX Load Balancer is fine.

我建议验证以下内容:

  1. Amazon EC2 Turn Server实例中的安全组应具有与您的负载均衡器配置匹配的入站端口.
  2. 检查轮流服务器上的配置文件,并验证其正在侦听的端口与您在负载均衡器上转发的端口是否相同.例如,您的NGINX配置上转发了TCP 3479.您需要确保转弯服务器正在侦听该端口.
  3. 最后,您可能还需要设置一些IP表,类似于在Turn Server上设置的IP表.查看您的Turn Server的配置,并查看是否需要在负载均衡器上进行任何iptables或ip6table配置.

这篇关于NGINX负载平衡转弯服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆