title: Filter request on proxy_pass using lua on nginx
body: <p>I want to filter streaming url before to streaming server using proxy_pass of nginx with lua</p>
  
  <p>My streaming server is <a href="http://localhost:8092" rel="nofollow">http://localhost:8092</a></p>
  
  <p>I want to when access to <a href="http://localhost:8080/streami1?token=mytoken" rel="nofollow">http://localhost:8080/streami1?token=mytoken</a> it will be forward to <a href="http://localhost:8092/stream1" rel="nofollow">http://localhost:8092/stream1</a>. If you access to <a href="http://localhost:8080/streaming1?token=abc" rel="nofollow">http://localhost:8080/streaming1?token=abc</a> it will be show permission deny page.</p>
  
  <p>It is my code on nginx configuration file:</p>
  
  <pre><code>  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";
     }
  </code></pre>
  
  <p>But, it not pass to my streaming insteaf of it show "You do not have permission: 1" when i request with url whether <a href="http://localhost:8080/streaming1?token=mytoken" rel="nofollow">http://localhost:8080/streaming1?token=mytoken</a>. Obviously, it change flag value to 1, but it do not pass to my streaming.
  What is my wrong?. Please help me?</p>