nginx-rtmp-module
nginx-rtmp-module copied to clipboard
on_publish, connection refuses no matter what I put in it.
I am trying to use on_publish to verify the stream key. If I forgot to provide something, go right ahead and ask.
I can curl from the host (of the server) and it works fine.
deny publish 10.49.197.1; is there so I can allow all local IPs and block the router, only local traffic is allowed.
RTMP config in nginx.conf:
rtmp {
server {
listen 1935;
chunk_size 4096;
allow publish 10.49.197.0/24;
deny publish 10.49.197.1;
deny publish all;
application live {
live on;
record off;
on_publish http://localhost:8080/verify;
# Twitch - Better Platform
#push rtmp://live.twitch.tv/app/[REDACTED];
# YouTube - Slower than Twitch
#push rtmp://a.rtmp.youtube.com/live2/[REDACTED];
}
}
}
sites-enabled/localhost:
server {
listen 127.0.0.1:8080;
server_name localhost;
if ($request_method !~ ^(GET|HEAD)$) { return 403; }
location /verify {
allow all;
expires off;
set $livepass 0;
if ($arg_livekey = "[My Nginx Stream Key]") { set $livepass 1; }
if ($livepass = 1) { return 200; }
return 401;
}
}
access.log:
10.49.197.54 [19/Nov/2023:00:54:46 +0000] PUBLISH "live" "[My Nginx Stream Key]" "" - 392 292 "" "FMLE/3.0 (compatible; FMSc/1.0)" (0s)
10.49.197.54 is my PC's local IP, I am testing by broadcasting from OBS on my PC.
error.log:
2023/11/19 00:54:46 [error] 11141#11141: recv() failed (111: Connection refused)
It took me probably an hour to track down, but after having a similar problem, it seems like you can't on_publish with a port. Adding a location / proxy_pass to the http { server } then passing to http://localhost/proxyed worked for me.