nginxvideo-streaminghttp-live-streamingkalturavod

NGINX open() failed (20: Not a directory) hls vod with secure link module


I have a problem with nginx config for hls streaming. I use kaltura nginx vod module and try to add ngx_http_secure_link_module to protect the stream. The strange thing is I have 404 error if I enable ngx_http_secure_link_module (logs below). I think that is because it can't find a file with index.m3u8 on the end, but if I comment secure link block it works fine.

Also I tried to add alias inside location ~ \.m3u8$ {} block, but it didn't work. What am I doing wrong? How to protect my stream?

My stream link: https://stream.example.com/hls/c14de868-3130-426a-a0cc-7ff6590e9a1f/index.m3u8?md5=0eNJ3SpBd87NGFF6Hw_zMQ&expires=1609448340

My NGINX config:

server {
  listen 9000;
  server_name localhost;
  # root /srv/static;

  location ^~ /hls/ {
    # the path to c14de868-3130-426a-a0cc-7ff6590e9a1f file
    alias /srv/static/videos/1/;
    # file with cors settings
    include cors.conf;

    vod hls;

    # 1. Set secret variable
    set $secret "s3cr3t";

    # 2. Set secure link
    secure_link $arg_md5,$arg_expires;
    secure_link_md5 "$secure_link_expires $secret";

    # if I comment this block everything works fine (but security)
    location ~ \.m3u8$ {
      if ($secure_link = "") { return 403; }
      if ($secure_link = "0") { return 403; }
    }
  }
}

NGINX logs:

cmdlogs


Solution

  • Just moved out this block to server directory and added vod hls; inside.

    location ~ \.m3u8$ {
      include cors.conf;
      vod hls;
    
      if ($secure_link = "") { return 403; }
      if ($secure_link = "0") { return 403; }
    }