[英]NGINX Load Balancing a Turn Server
I am attempting to put a Load Balancer in front of a Turn Server for use with WebRTC. 我试图将负载均衡器放在Turn Server前面,以与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:
转向服务器需要多个端口,包括一个UDP,如下所示:
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. 我试图将Amazon Elastic Load Balancer(AWS ELB)放置在Turn Server的前面,但是它不支持UDP端口。 So I am now running Ubuntu on an EC2 Instance with all these ports open and I have installed NGINX.
所以我现在在所有这些端口都打开的EC2实例上运行Ubuntu,并且我已经安装了NGINX。
I've edited the /etc/nginx/nginx.conf file and added a "stream" section to it with both upstream and servers for each port. 我已经编辑了/etc/nginx/nginx.conf文件,并为每个端口的上游和服务器添加了“ stream”部分。 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;
}
}
I have also created a custom load balancer configuration file at /etc/nginx/conf.d/load-balancer.conf and placed the following in it. 我还在/etc/nginx/conf.d/load-balancer.conf中创建了一个自定义的负载均衡器配置文件,并将以下内容放入其中。
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;
}
}
The http and https traffic appear to be working fine based on the custom load-balancer.conf file. 基于自定义load-balancer.conf文件,http和https流量似乎运行良好。
I am unsure why the TCP/UDP Ports I have configured in the ngnix.conf file are not working as intended. 我不确定为什么在ngnix.conf文件中配置的TCP / UDP端口无法正常工作。
Your configuration of the NGINX Load Balancer is fine. 您可以对NGINX负载均衡器进行配置。
I suggest verifying the following: 我建议验证以下内容:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.