I'm getting the following error in the RTMP block of my nginx.conf when I attempt to run it in a dockerized setup.
[emerg] 1#1: host not found in url "api-servers/api/livevideostreams/startlivevideostream;
When Nginx attempts to read the one_publish and on_publish_done lines part of the rtmp block :
rtmp { server { listen 1935; on_publish http://api-servers/api/livevideostreams/startlivevideostream; on_publish_done http://api-servers/api/livevideostreams/stoplivevideostream; } } The upstream block is defined as
upstream api-servers { # Here we can specify multiple upstream servers of django api for load balancing. server 172.16.16.6:7575;# load balancing server 1 server 172.16.16.7:8585;# load balancing server 2 } The http code block which proxies the upstream server:
http { server{ listen 8080; location / { proxy_pass http://api-servers; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_buffering on; proxy_cache my_zone; add_header X-Proxy-Cache $upstream_cache_status; # WebSocket support (nginx 1.4) proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_redirect off; } } } Note : I'm Building a live streaming application using nginx rtmp module. I've attached relevant code only. The 2 upstream api servers are listening on 2 separate docker containers. the media server is a separate container as well where nginx.conf is configured.
I also tested the above nginx.conf without the rtmp block and I'm able to successfully hit the upstream blocks. Made 4 requests, 3 of them hit the 1st load balancing server and the 4th hit the 2nd load balancing server after checking the access logs. There is some issue with resolving the rtmp part of upstream servers.
Thank you in advance.
on_publish http://localhost:8080/api/livevideostreams/startlivevideostream;since it will be proxied to one of two upstreams and thats what you want.