Welcome! Log In Create A New Profile

Advanced

Are Multiple servers of the same type allowed in nginx.conf?

Posted by rayj00 
Are Multiple servers of the same type allowed in nginx.conf?
June 11, 2018 11:21AM
I am wondering if it is legal to have multiple servers of the same type. In my case, I need multiple rtmp servers
that service specific users. Rather than having multiple physical machines, I am thinking LXD containers would be nice to use. Each container has a media server.

I am using OBS on my PC (192.168.0.5) to stream rtmp. I am using a Vboxt PC VM 192.168.0.47 Ubuntu 16.04 to
host the two containers which are also Ubuntu 16.04.

So, initially I tried with only the push directive. That did not work as I was getting chunk size failures all over the place.
Apparently the rtmp module is not being supported any longer? Arun does not respond to my emails. This is a bummer!

But anyway, I'm thinking I can configure the OBS stream settings as such: rtmp://192.168.0.47:1935/LPC1,
or rtmp://192.168.0.47:1936/LPC2 and the rtmp will be routed to the proper container using iptables.

So now I am using iptables to forward incoming rtmp to specific containers. Here are the iptables commands:

iptables -t nat -A PREROUTING -p tcp -i enp0s3 --dport 1935 -j DNAT --to-destination 10.57.215.214 :1935
iptables -t nat -A PREROUTING -p tcp -i enp0s3 --dport 1936 -j DNAT --to-destination 10.57.215.247 :1935

This works for the first route....input port 1935 gets routed to the proper container port 1935.
However, if I try to stream to port 1936, it also gets routed to the first container rather than the second one.

Here is my .conf:


#user nobody;
worker_processes 2;

error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
error_log logs/debug.log debug;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}

rtmp {
server {
listen 1935;
ping 30s;
ping_timeout 10s;
chunk_size 4096;

application LPC1 {
live on;
# push rtmp://10.57.215.214:1935;

}
}
}

rtmp {
server {
listen 1936;
ping 30s;
ping_timeout 10s;
chunk_size 4096;

application LPC2 {
live on;
# push rtmp://10.57.215.247:1935;

}
}
}

And here is the netstat output. As you can see, both ports are being listened to:

sudo netstat -tulpn
[sudo] password for ray:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1011/sshd
tcp 0 0 0.0.0.0:1935 0.0.0.0:* LISTEN 5752/nginx
tcp 0 0 0.0.0.0:1936 0.0.0.0:* LISTEN 5752/nginx
tcp 0 0 10.57.215.1:53 0.0.0.0:* LISTEN 1481/dnsmasq
tcp6 0 0 :::22 :::* LISTEN 1011/sshd
tcp6 0 0 fd42:2bf8:ea23:1a35::53 :::* LISTEN 1481/dnsmasq
tcp6 0 0 fe80::78af:32ff:fe9e:53 :::* LISTEN 1481/dnsmasq
udp 0 0 10.57.215.1:53 0.0.0.0:* 1481/dnsmasq
udp 0 0 0.0.0.0:67 0.0.0.0:* 1481/dnsmasq
udp 0 0 0.0.0.0:68 0.0.0.0:* 823/dhclient
udp6 0 0 :::547 :::* 1481/dnsmasq
udp6 0 0 fd42:2bf8:ea23:1a35::53 :::* 1481/dnsmasq
udp6 0 0 fe80::78af:32ff:fe9e:53 :::* 1481/dnsmasq

Any idea why this is not working? Why is port 1936 going to 10.57.215.214 rather than 10.57.215.247?

Thanks, this is driving me crazy!

Ray
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 74
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 214 on March 20, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready