6

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.

Also tried following config:

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://loclahost.com: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.

The output of nginx -V is:

nginx version: nginx/1.6.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'

I can read the $_SERVER["HTTP_X_ORIGINAL_URI"] in php, but I like to have the vars just as $_GET. This doesn't seem to work.

As you can see from the logs below, only the $is_args variable is added in the subrequest. The debug.log is below:

2014/06/27 08:41:59 [debug] 27994#0: timer delta: 0
2014/06/27 08:41:59 [debug] 27994#0: posted events 0000000000000000
2014/06/27 08:41:59 [debug] 27994#0: worker cycle
2014/06/27 08:41:59 [debug] 27994#0: epoll timer: 59029
2014/06/27 08:42:00 [debug] 27994#0: epoll: fd:6 ev:0001 d:00000000017C7450
2014/06/27 08:42:00 [debug] 27994#0: accept on IP:80, ready: 0
2014/06/27 08:42:00 [debug] 27994#0: posix_memalign: 00000000017BB920:256 @16
2014/06/27 08:42:00 [debug] 27994#0: *39 accept: IP fd:3
2014/06/27 08:42:00 [debug] 27994#0: posix_memalign: 00000000017BBA80:256 @16
2014/06/27 08:42:00 [debug] 27994#0: *39 event timer add: 3: 60000:1403851380198
2014/06/27 08:42:00 [debug] 27994#0: *39 reusable connection: 1
2014/06/27 08:42:00 [debug] 27994#0: *39 epoll add event: fd:3 op:1 ev:80002001
2014/06/27 08:42:00 [debug] 27994#0: timer delta: 319
2014/06/27 08:42:00 [debug] 27994#0: posted events 0000000000000000
2014/06/27 08:42:00 [debug] 27994#0: worker cycle
2014/06/27 08:42:00 [debug] 27994#0: epoll timer: 58710
2014/06/27 08:42:00 [debug] 27994#0: epoll: fd:3 ev:0001 d:00000000017C7961
2014/06/27 08:42:00 [debug] 27994#0: *39 http wait request handler
2014/06/27 08:42:00 [debug] 27994#0: *39 malloc: 00000000017972F0:1024
2014/06/27 08:42:00 [debug] 27994#0: *39 recv: fd:3 390 of 1024
2014/06/27 08:42:00 [debug] 27994#0: *39 reusable connection: 0
2014/06/27 08:42:00 [debug] 27994#0: *39 posix_memalign: 00000000018354C0:4096 @16
2014/06/27 08:42:00 [debug] 27994#0: *39 http process request line
2014/06/27 08:42:00 [debug] 27994#0: *39 http request line: "GET /hls/group/rsdrsd.m3u8?user=rsdrsd2 HTTP/1.1"
2014/06/27 08:42:00 [debug] 27994#0: *39 http uri: "/hls/group/rsdrsd.m3u8"
2014/06/27 08:42:00 [debug] 27994#0: *39 http args: "user=rsdrsd2"
2014/06/27 08:42:00 [debug] 27994#0: *39 http exten: "m3u8"
2014/06/27 08:42:00 [debug] 27994#0: *39 posix_memalign: 00000000018364D0:4096 @16
2014/06/27 08:42:00 [debug] 27994#0: *39 http process request header line
2014/06/27 08:42:00 [debug] 27994#0: *39 http header: "Host: domain.com"
2014/06/27 08:42:00 [debug] 27994#0: *39 http header: "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0"
2014/06/27 08:42:00 [debug] 27994#0: *39 http header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
2014/06/27 08:42:00 [debug] 27994#0: *39 http header: "Accept-Language: en-US,en;q=0.5"
2014/06/27 08:42:00 [debug] 27994#0: *39 http header: "Accept-Encoding: gzip, deflate"
2014/06/27 08:42:00 [debug] 27994#0: *39 http header: "Cookie: PHPSESSID=c3m0rkb9il0udfgoh9qt91jao0"
2014/06/27 08:42:00 [debug] 27994#0: *39 http header: "Connection: keep-alive"
2014/06/27 08:42:00 [debug] 27994#0: *39 http header: "Cache-Control: max-age=0"
2014/06/27 08:42:00 [debug] 27994#0: *39 http header done
2014/06/27 08:42:00 [debug] 27994#0: *39 event timer del: 3: 1403851380198
2014/06/27 08:42:00 [debug] 27994#0: *39 generic phase: 0
2014/06/27 08:42:00 [debug] 27994#0: *39 rewrite phase: 1
2014/06/27 08:42:00 [debug] 27994#0: *39 test location: "/hls/auth-update"
2014/06/27 08:42:00 [debug] 27994#0: *39 test location: "/hls/public"
2014/06/27 08:42:00 [debug] 27994#0: *39 test location: ~ "[^/]\.php(/|$)"
2014/06/27 08:42:00 [debug] 27994#0: *39 test location: ~ "^/hls/(private|group)/([0-9a-zA-Z]+)\.m3u8"
2014/06/27 08:42:00 [debug] 27994#0: *39 using configuration "^/hls/(private|group)/([0-9a-zA-Z]+)\.m3u8"
2014/06/27 08:42:00 [debug] 27994#0: *39 http cl:-1 max:1048576
2014/06/27 08:42:00 [debug] 27994#0: *39 rewrite phase: 3
2014/06/27 08:42:00 [debug] 27994#0: *39 post rewrite phase: 4
2014/06/27 08:42:00 [debug] 27994#0: *39 generic phase: 5
2014/06/27 08:42:00 [debug] 27994#0: *39 generic phase: 6
2014/06/27 08:42:00 [debug] 27994#0: *39 generic phase: 7
2014/06/27 08:42:00 [debug] 27994#0: *39 access phase: 8
2014/06/27 08:42:00 [debug] 27994#0: *39 access phase: 9
2014/06/27 08:42:00 [debug] 27994#0: *39 access phase: 10
2014/06/27 08:42:00 [debug] 27994#0: *39 auth request handler
2014/06/27 08:42:00 [debug] 27994#0: *39 http subrequest "/hls/auth-play?"
2014/06/27 08:42:00 [debug] 27994#0: *39 http posted request: "/hls/auth-play?"
2014/06/27 08:42:00 [debug] 27994#0: *39 rewrite phase: 1
2014/06/27 08:42:00 [debug] 27994#0: *39 test location: "/hls/auth-update"
2014/06/27 08:42:00 [debug] 27994#0: *39 test location: "/hls/auth-play"
2014/06/27 08:42:00 [debug] 27994#0: *39 test location: ~ "[^/]\.php(/|$)"
2014/06/27 08:42:00 [debug] 27994#0: *39 test location: ~ "^/hls/(private|group)/([0-9a-zA-Z]+)\.m3u8"
2014/06/27 08:42:00 [debug] 27994#0: *39 test location: ~ "^/hls/(private|group)/([0-9a-zA-Z]+)\-([0-9]+)\.ts"
2014/06/27 08:42:00 [debug] 27994#0: *39 test location: ~ "^/chat/(?<node>(3000))"
2014/06/27 08:42:00 [debug] 27994#0: *39 using configuration "/hls/auth-play"
2014/06/27 08:42:00 [debug] 27994#0: *39 http cl:-1 max:1048576
2014/06/27 08:42:00 [debug] 27994#0: *39 rewrite phase: 3
2014/06/27 08:42:00 [debug] 27994#0: *39 post rewrite phase: 4
2014/06/27 08:42:00 [debug] 27994#0: *39 generic phase: 5
2014/06/27 08:42:00 [debug] 27994#0: *39 generic phase: 6
2014/06/27 08:42:00 [debug] 27994#0: *39 generic phase: 7
2014/06/27 08:42:00 [debug] 27994#0: *39 posix_memalign: 00000000018374E0:4096 @16
2014/06/27 08:42:00 [debug] 27994#0: *39 http script copy: "http://127.0.0.1:8080/on_play.php"
2014/06/27 08:42:00 [debug] 27994#0: *39 http script var: ""
2014/06/27 08:42:00 [debug] 27994#0: *39 http init upstream, client timer: 0
2014/06/27 08:42:00 [debug] 27994#0: *39 epoll add event: fd:3 op:3 ev:80002005
2014/06/27 08:42:00 [debug] 27994#0: *39 http script copy: "X-Original-URI: "
2014/06/27 08:42:00 [debug] 27994#0: *39 http script var: "/hls/group/rsdrsd.m3u8?user=rsdrsd2"
2014/06/27 08:42:00 [debug] 27994#0: *39 http script copy: "^M
"
2014/06/27 08:42:00 [debug] 27994#0: *39 http script copy: "Host: "
2014/06/27 08:42:00 [debug] 27994#0: *39 http script var: "127.0.0.1:8080"
2014/06/27 08:42:00 [debug] 27994#0: *39 http script copy: "^M
"
2014/06/27 08:42:00 [debug] 27994#0: *39 http script copy: "Connection: close^M
"
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy header: "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0"
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy header: "Accept-Language: en-US,en;q=0.5"
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy header: "Accept-Encoding: gzip, deflate"
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy header: "Cookie: PHPSESSID=c3m0rkb9il0udfgoh9qt91jao0"
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy header: "Cache-Control: max-age=0"
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy header:
"GET /on_play.php HTTP/1.0^M
X-Original-URI: /hls/group/rsdrsd.m3u8?user=rsdrsd2^M
Host: 127.0.0.1:8080^M
Connection: close^M
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0^M
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8^M
Accept-Language: en-US,en;q=0.5^M
Accept-Encoding: gzip, deflate^M
Cookie: PHPSESSID=c3m0rkb9il0udfgoh9qt91jao0^M
Cache-Control: max-age=0^M
^M
"
2014/06/27 08:42:00 [debug] 27994#0: *39 http cleanup add: 0000000001837A58
2014/06/27 08:42:00 [debug] 27994#0: *39 get rr peer, try: 1
2014/06/27 08:42:00 [debug] 27994#0: *39 socket 10
2014/06/27 08:42:00 [debug] 27994#0: *39 epoll add connection: fd:10 ev:80002005
2014/06/27 08:42:00 [debug] 27994#0: *39 connect to 127.0.0.1:8080, fd:10 #40
2014/06/27 08:42:00 [debug] 27994#0: *39 http upstream connect: -2
2014/06/27 08:42:00 [debug] 27994#0: *39 posix_memalign: 0000000001789700:128 @16
2014/06/27 08:42:00 [debug] 27994#0: *39 event timer add: 10: 60000:1403851380199
2014/06/27 08:42:00 [debug] 27994#0: *39 http finalize request: -4, "/hls/auth-play?" a:1, c:3
2014/06/27 08:42:00 [debug] 27994#0: *39 http request count:3 blk:0
2014/06/27 08:42:00 [debug] 27994#0: timer delta: 1
2014/06/27 08:42:00 [debug] 27994#0: posted events 0000000000000000
2014/06/27 08:42:00 [debug] 27994#0: worker cycle
2014/06/27 08:42:00 [debug] 27994#0: epoll timer: 58709
2014/06/27 08:42:00 [debug] 27994#0: epoll: fd:3 ev:0004 d:00000000017C7961
2014/06/27 08:42:00 [debug] 27994#0: *39 http run request: "/hls/auth-play?"
2014/06/27 08:42:00 [debug] 27994#0: *39 http upstream check client, write event:1, "/hls/auth-play"
2014/06/27 08:42:00 [debug] 27994#0: *39 http upstream recv(): -1 (11: Resource temporarily unavailable)
2014/06/27 08:42:00 [debug] 27994#0: epoll: fd:10 ev:0004 d:00000000017C7A39
2014/06/27 08:42:00 [debug] 27994#0: *39 http upstream request: "/hls/auth-play?"
2014/06/27 08:42:00 [debug] 27994#0: *39 http upstream send request handler
2014/06/27 08:42:00 [debug] 27994#0: *39 http upstream send request
2014/06/27 08:42:00 [debug] 27994#0: *39 chain writer buf fl:1 s:419
2014/06/27 08:42:00 [debug] 27994#0: *39 chain writer in: 00000000018374C0
2014/06/27 08:42:00 [debug] 27994#0: *39 writev: 419
2014/06/27 08:42:00 [debug] 27994#0: *39 chain writer out: 0000000000000000
2014/06/27 08:42:00 [debug] 27994#0: *39 event timer del: 10: 1403851380199
2014/06/27 08:42:00 [debug] 27994#0: *39 event timer add: 10: 60000:1403851380199
2014/06/27 08:42:00 [debug] 27994#0: timer delta: 0
2014/06/27 08:42:00 [debug] 27994#0: posted events 0000000000000000
2014/06/27 08:42:00 [debug] 27994#0: worker cycle
2014/06/27 08:42:00 [debug] 27994#0: epoll timer: 58709
2014/06/27 08:42:00 [debug] 27994#0: epoll: fd:10 ev:0005 d:00000000017C7A39
2014/06/27 08:42:00 [debug] 27994#0: *39 http upstream request: "/hls/auth-play?"
2014/06/27 08:42:00 [debug] 27994#0: *39 http upstream process header
2014/06/27 08:42:00 [debug] 27994#0: *39 malloc: 00000000018384F0:4096
2014/06/27 08:42:00 [debug] 27994#0: *39 recv: fd:10 154 of 4096
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy status 403 "403 Forbidden"
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy header: "Server: nginx/1.6.0"
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy header: "Date: Fri, 27 Jun 2014 06:42:00 GMT"
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy header: "Content-Type: text/html"
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy header: "Connection: close"
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy header: "X-Powered-By: PHP/5.5.10"
2014/06/27 08:42:00 [debug] 27994#0: *39 http proxy header done
2014/06/27 08:42:00 [debug] 27994#0: *39 finalize http upstream request: 0
2014/06/27 08:42:00 [debug] 27994#0: *39 finalize http proxy request
2014/06/27 08:42:00 [debug] 27994#0: *39 free rr peer 1 0
2014/06/27 08:42:00 [debug] 27994#0: *39 close http upstream connection: 10
2014/06/27 08:42:00 [debug] 27994#0: *39 free: 0000000001789700, unused: 48
2014/06/27 08:42:00 [debug] 27994#0: *39 event timer del: 10: 1403851380199
2014/06/27 08:42:00 [debug] 27994#0: *39 reusable connection: 0
2014/06/27 08:42:00 [debug] 27994#0: *39 http finalize request: 0, "/hls/auth-play?" a:1, c:2
2014/06/27 08:42:00 [debug] 27994#0: *39 auth request done s:403
2014/06/27 08:42:00 [debug] 27994#0: *39 http wake parent request: "/hls/group/rsdrsd.m3u8?user=rsdrsd2"
2014/06/27 08:42:00 [debug] 27994#0: *39 http posted request: "/hls/group/rsdrsd.m3u8?user=rsdrsd2"
2014/06/27 08:42:00 [debug] 27994#0: *39 access phase: 10
2014/06/27 08:42:00 [debug] 27994#0: *39 auth request handler
2014/06/27 08:42:00 [debug] 27994#0: *39 auth request set variables
2014/06/27 08:42:00 [debug] 27994#0: *39 http finalize request: 403, "/hls/group/rsdrsd.m3u8?user=rsdrsd2" a:1, c:1
2014/06/27 08:42:00 [debug] 27994#0: *39 http special response: 403, "/hls/group/rsdrsd.m3u8?user=rsdrsd2"
2014/06/27 08:42:00 [debug] 27994#0: *39 http set discard body
2014/06/27 08:42:00 [debug] 27994#0: *39 HTTP/1.1 403 Forbidden^M
Server: nginx/1.6.0^M
Date: Fri, 27 Jun 2014 06:42:00 GMT^M
Content-Type: text/html^M
Content-Length: 168^M
Connection: keep-alive^M

2014/06/27 08:42:00 [debug] 27994#0: *39 write new buf t:1 f:0 0000000001837DC8, pos 0000000001837DC8, size: 154 file: 0, size: 0
2014/06/27 08:42:00 [debug] 27994#0: *39 http write filter: l:0 f:0 s:154
2014/06/27 08:42:00 [debug] 27994#0: *39 http output filter "/hls/group/rsdrsd.m3u8?user=rsdrsd2"
2014/06/27 08:42:00 [debug] 27994#0: *39 http copy filter: "/hls/group/rsdrsd.m3u8?user=rsdrsd2"
2014/06/27 08:42:00 [debug] 27994#0: *39 http postpone filter "/hls/group/rsdrsd.m3u8?user=rsdrsd2" 0000000001837F98
2014/06/27 08:42:00 [debug] 27994#0: *39 write old buf t:1 f:0 0000000001837DC8, pos 0000000001837DC8, size: 154 file: 0, size: 0
2014/06/27 08:42:00 [debug] 27994#0: *39 write new buf t:0 f:0 0000000000000000, pos 00000000006CD6E0, size: 116 file: 0, size: 0
2014/06/27 08:42:00 [debug] 27994#0: *39 write new buf t:0 f:0 0000000000000000, pos 00000000006CD0C0, size: 52 file: 0, size: 0
2014/06/27 08:42:00 [debug] 27994#0: *39 http write filter: l:1 f:0 s:322
2014/06/27 08:42:00 [debug] 27994#0: *39 http write filter limit 0
2014/06/27 08:42:00 [debug] 27994#0: *39 writev: 322
2014/06/27 08:42:00 [debug] 27994#0: *39 http write filter 0000000000000000
2014/06/27 08:42:00 [debug] 27994#0: *39 http copy filter: 0 "/hls/group/rsdrsd.m3u8?user=rsdrsd2"
2014/06/27 08:42:00 [debug] 27994#0: *39 http finalize request: 0, "/hls/group/rsdrsd.m3u8?user=rsdrsd2" a:1, c:1
2014/06/27 08:42:00 [debug] 27994#0: *39 set http keepalive handler
2014/06/27 08:42:00 [debug] 27994#0: *39 http close request
2014/06/27 08:42:00 [debug] 27994#0: *39 http log handler
2014/06/27 08:42:00 [debug] 27994#0: *39 free: 00000000018384F0
2014/06/27 08:42:00 [debug] 27994#0: *39 free: 00000000018354C0, unused: 8
2014/06/27 08:42:00 [debug] 27994#0: *39 free: 00000000018364D0, unused: 0
2014/06/27 08:42:00 [debug] 27994#0: *39 free: 00000000018374E0, unused: 1069
2014/06/27 08:42:00 [debug] 27994#0: *39 free: 00000000017972F0
2014/06/27 08:42:00 [debug] 27994#0: *39 hc free: 0000000000000000 0
2014/06/27 08:42:00 [debug] 27994#0: *39 hc busy: 0000000000000000 0
2014/06/27 08:42:00 [debug] 27994#0: *39 tcp_nodelay
2014/06/27 08:42:00 [debug] 27994#0: *39 reusable connection: 1
2014/06/27 08:42:00 [debug] 27994#0: *39 event timer add: 3: 3000:1403851323212
2014/06/27 08:42:00 [debug] 27994#0: *39 post event 00000000017FD6D0
2014/06/27 08:42:00 [debug] 27994#0: timer delta: 13
2014/06/27 08:42:00 [debug] 27994#0: posted events 00000000017FD6D0
2014/06/27 08:42:00 [debug] 27994#0: posted event 00000000017FD6D0
2014/06/27 08:42:00 [debug] 27994#0: *39 delete posted event 00000000017FD6D0
2014/06/27 08:42:00 [debug] 27994#0: *39 http keepalive handler
2014/06/27 08:42:00 [debug] 27994#0: *39 malloc: 00000000017972F0:1024
2014/06/27 08:42:00 [debug] 27994#0: *39 recv: fd:3 -1 of 1024
2014/06/27 08:42:00 [debug] 27994#0: *39 recv() not ready (11: Resource temporarily unavailable)
2014/06/27 08:42:00 [debug] 27994#0: *39 free: 00000000017972F0
2014/06/27 08:42:00 [debug] 27994#0: posted event 0000000000000000
2014/06/27 08:42:00 [debug] 27994#0: worker cycle
2014/06/27 08:42:00 [debug] 27994#0: epoll timer: 3000
2014/06/27 08:42:03 [debug] 27994#0: timer delta: 3003
2014/06/27 08:42:03 [debug] 27994#0: *39 event timer del: 3: 1403851323212
2014/06/27 08:42:03 [debug] 27994#0: *39 http keepalive handler
2014/06/27 08:42:03 [debug] 27994#0: *39 close http connection: 3
2014/06/27 08:42:03 [debug] 27994#0: *39 reusable connection: 0
2014/06/27 08:42:03 [debug] 27994#0: *39 free: 0000000000000000
2014/06/27 08:42:03 [debug] 27994#0: *39 free: 00000000017BB920, unused: 0
2014/06/27 08:42:03 [debug] 27994#0: *39 free: 00000000017BBA80, unused: 120
2014/06/27 08:42:03 [debug] 27994#0: posted events 0000000000000000
2014/06/27 08:42:03 [debug] 27994#0: worker cycle
2014/06/27 08:42:03 [debug] 27994#0: epoll timer: 55693
6
  • proxy_pass localhost.com:8080/on_play.php$is_args$args; Commented Jun 26, 2014 at 16:52
  • Already tried that one, but that also doesn't work. The args don't get passed to location /hls/auth Commented Jun 26, 2014 at 19:57
  • can you please provide the logs with debug level? And the output of nginx -V as well. Commented Jun 26, 2014 at 20:54
  • Added debug.log and nginx -V. The debug.log is for: proxy_pass localhost.com:8080/on_play.php$is_args$args; Commented Jun 27, 2014 at 6:56
  • This is driving me nuts. Any luck on this? Commented Aug 21, 2014 at 15:24

1 Answer 1

6

Got something similar to work like this:

location ~ ^/something/([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/(.*)$ {
    set $auth_request_uri "http://127.0.0.1/api/something/$1/access/$2";
    auth_request /auth;

    alias $SOMEPATH/public/files/$2/$3;
}

location /auth {
    internal;
    proxy_pass $auth_request_uri;
    proxy_pass_request_body off;
    proxy_set_header Content-Length "";
    proxy_set_header X-Original-URI $request_uri;
}
Sign up to request clarification or add additional context in comments.

2 Comments

This works for me, but it worries me because I'm not really sure how nginx variables work. It looks like $auth_request_uri is effectively being used as a global variable. In this case, could one client request set the variable, then authorise a separate client request ? (A race condition)
@ddouglascarr I would have thought the vars is contained in each request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.