【发布时间】:2016-03-31 12:59:08
【问题描述】:
我想使用带有 lua 的 nginx 的 proxy_pass 在流媒体服务器之前过滤流媒体 url
我的流媒体服务器是http://localhost:8092
我想在访问http://localhost:8080/streami1?token=mytoken 时转发到http://localhost:8092/stream1。如果您访问http://localhost:8080/streaming1?token=abc,它将显示权限拒绝页面。
这是我在 nginx 配置文件上的代码:
location ^~ /stream {
set $flag_false "false";
set $flag "false";
set $flag_true 1;
rewrite_by_lua '
local token = ngx.var.arg_token
if token == "mytoken" then
ngx.var.flag = ngx.var.flag_true
end
';
# rewrite_by_lua "ngx.var.flag = ngx.var.flag_true";
if ($flag = $flag_true) {
proxy_pass http://x.x.x.x:8092;
break;
}
echo "You do not have permission: $flag";
}
但是,当我使用 url 请求 http://localhost:8080/streaming1?token=mytoken 时,它不会传递给我的流媒体,而是显示“您没有权限:1”。显然,它将标志值更改为 1,但它不会传递给我的流媒体。 我怎么了?。请帮帮我?
【问题讨论】: