Question
Node media server (RTMP) NGINX config
Hello,
I had a node media server running on a DO droplet and it was working as expected but now I want to migrate all my services to a different droplet because I have other domains running on the first droplet so the problem is the following:
I have:
example.com
example2.com
example3.com
when I run node media server all domains can access the rmtp and I want only example.com to access it.
My idea was to use a reverse proxy for all my services this way:
server {
server_name rtmp.example.com www.rtmp.example.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
proxy_pass http://localhost:3003/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
server {
server_name api.example.com www.api.example.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
proxy_pass http://localhost:3001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
But it is not working and I think nginx is blocking the rtmp protocol.
Do you know how can I enable rtmp traffic
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×