我尝试为on_play设置安全链接 和 on_publish 并没有成功,那我只是试着设置为例子
但它仍然无效,只是第一个请求没问题,其他请求没有发送secure_link参数
我的nginx.cong是
user root root;
worker_processes 3;
worker_rlimit_nofile 108000;
worker_priority -5;
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
pid /tmp/nginx.pid;
events {
use epoll;
worker_connections 500;
}
http {
vhost_traffic_status_zone;
include /opt/nginx/conf/mime.types;
default_type application/octet-stream;
log_subrequest off;
access_log /opt/nginx/logs/access.log ;
error_log /opt/nginx/logs/error.log crit;
log_subrequest on;
server {
listen 8080;
server_name localhost;
location /on_play {
# set connection secure link
secure_link $arg_st,$arg_e;
secure_link_md5 mysecretkey$arg_app/$arg_name$arg_e;
# bad hash
if ($secure_link = "") {
return 501;
}
# link expired
if ($secure_link = "0") {
return 502;
}
return 200;
}
}
server {
listen 80;
server_name localhost;
## RTMP STAT CONTROL
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
# you can move stat.xsl to a different location
root /opt/nginx/html/rtmp;
}
# rtmp control
location /control {
rtmp_control all;
}
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
}
}
##rtmp Stream
rtmp {
server {
listen 1935;
chunk_size 4000;
application myapp {
live on;
notify_method get;
on_play http://localhost:8080/on_play;
}
}
}
我使用ffmpeg作为发布商 和vlc作为一名球员 播放链接是rtmp://172.16.1.166/myapp/mystream?e = 1482160069& st = U7sDGG1X3XdOpjR4QJqd8w 在access.log我可以看到
127.0.0.1 - - [19/Dec/2016:17:21:07 +0300] "GET /on_play?app=myapp&flashver=LNX%209,0,124,2&swfurl=&tcurl=rtmp://172.16.1.166:1935/myapp&pageurl=&addr=172.16.1.7&clientid=1&call=play&name=mystream&start=4294965296&duration=0&reset=0&e=1482160069&st=U7sDGG1X3XdOpjR4QJqd8w HTTP/1.0" 200 0 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:23 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.0&clientid=5&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:23 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.1&clientid=7&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:24 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.0&clientid=13&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:24 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.1&clientid=15&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:25 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.0&clientid=21&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:25 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.1&clientid=23&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:26 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.0&clientid=29&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:26 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.1&clientid=31&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:27 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.0&clientid=37&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:27 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.1&clientid=39&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:28 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.0&clientid=45&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:28 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.1&clientid=47&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:29 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.0&clientid=53&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:29 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.1&clientid=55&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:30 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.1&clientid=63&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:30 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.0&clientid=61&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
127.0.0.1 - - [19/Dec/2016:17:21:31 +0300] "GET /on_play?app=&flashver=ngx-local-relay&swfurl=&tcurl=&pageurl=&addr=unix:/tmp/nginx-rtmp.1&clientid=71&call=play&name=mystream&start=0&duration=0&reset=0 HTTP/1.0" 501 181 "-" "-"
看起来好像只是第一次请求就好了200
所有下一个请求都没有参数,他们被拒绝
:((
P.S。 我试过ffplay,result和access.log相同的
答案 0 :(得分:0)
这里的问题相同。我只是将on_play重定向到另一个网页,如果参数包含“addr = unix ...”则发送200,如果addr不同,则检查其他参数。