Welcome! Log In Create A New Profile

Advanced

Pass arguments to auth_request module from nginx

Posted by rsdrsd 
Pass arguments to auth_request module from nginx
June 26, 2014 10:38AM
I want to protext a live HLS stream. I want to use the auth_request module. I want to check if a request is valid by passing a key. So something like: http://domain.com/hls/stream.m3u8?key=xxxxxxx

I have the following setup in nginx.conf:
location /hls {
alias /tmp/hls;
auth_request /hls/auth;
}

location /hls/auth {
proxy_pass http://localhost.com:8080/on_play.php;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}

Now I need to get the key=xxxxx available in http://localhost.com:8080/on_play.php.

I tried a lot but nothing seems to work. I also tried something like:
location /hls {
alias /tmp/hls;
auth_request http://localhost.com:8080/on_play.php?key=$arg_key;
}

But this also doesn't work. There seems not to be a possibility as of to get the key argument in the on_play.php

The $_SERVER["REQUEST_URI"] also doesn't contain the args.
Re: Pass arguments to auth_request module from nginx
June 26, 2014 03:55PM
I also tried something like this, but this also doesn't work:

location ~ ^/hls/(long|short)/([0-9a-zA-Z]+)\.m3u8 {
alias /tmp/hls/$1/$2.m3u8;
auth_request /hls/auth-play/$1/$2;
}

location ~ ^/hls/auth-play/(long|short)/([0-9a-zA-Z]+) {
proxy_pass http://127.0.0.1:8080/on_play.php?app=$1&room=$2;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}

But this also doesn't work.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 127
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready