4

I want to use video streaming with nginx for windows server. I have this nginx config:

#user  nobody;
worker_processes  1;

error_log  logs/error.log;
error_log  logs/error.log  notice;
error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    proxy_max_temp_file_size 0;
    proxy_cache_path /nginx/cache levels=1:2 keys_zone=STATIC:1000m max_size=1000m inactive=720m;
    proxy_temp_path /nginx/tmp;

    server {
        listen       81;
        server_name  127.0.0.1;

        location ~* .(jpe?g|gif|png|ico|css|pdf|ppt|txt|bmp|rtf|js)$ {
            access_log off;

            proxy_pass http://10.1.4.22:9001;
            proxy_cache STATIC;
            proxy_ignore_headers "Set-Cookie";
            proxy_hide_header "Set-Cookie";
        }

        location / {
            proxy_pass http://10.1.4.22:9001;
        }

        location ~* /!/scorms.ecp/\d+(/.*\.(mp4|webm|ogv))$ {
            root /video;
            proxy_pass http://10.1.4.22:9001;
            rewrite /!/scorms.ecp/\d+/(\w+)/\d+/\d+/\w+/(.+) /$1/$2 break;
            try_files $1 @fallback;
            error_log  logs/error.log  debug;
            flv;
            mp4;
            mp4_buffer_size       512k;
            mp4_max_buffer_size   1m;
            #mp4_limit_rate        on;
            #mp4_limit_rate_after  30s;
    }

        location @fallback {
            proxy_pass http://10.1.4.22:9001;
            flv;
            mp4;
            mp4_buffer_size       512k;
            mp4_max_buffer_size   1m;
        }
    }   
}

The most important thing in this config is:

location ~* /!/scorms.ecp/\d+(/.*\.(mp4|webm|ogv))$ {
        root /video;
        proxy_pass http://10.1.4.22:9001;
        rewrite /!/scorms.ecp/\d+/(\w+)/\d+/\d+/\w+/(.+) /$1/$2 break;
        try_files $1 @fallback;
        error_log  logs/error.log  debug;
        flv;
        mp4;
        mp4_buffer_size       512k;
        mp4_max_buffer_size   1m;
        #mp4_limit_rate        on;
        #mp4_limit_rate_after  30s;
}

I send request http://host:port/!/scorms.ecp/27/TESTC/1/1/images/pravilo2.mp4. In error.log I have:

2016/05/25 09:53:19 [error] 9200#7996: *1 CreateFile() "D:\PAPISDK_4_T\nginx-1.10.0/html/TESTC/pravilo11.mp4" failed (3: The system cannot find the path specified), client: 10.1.4.22, server: 127.0.0.1, request: "GET /!/scorms.ecp/27/TESTC/1/1/images/pravilo11.mp4 HTTP/1.1", host: "10.1.4.22:81", referrer: "http://10.1.4.22:81/!/scorms.ecp/27/TESTC/1/1/start.html"

I don`t understand why nginx try to find "D:\PAPISDK_4_T\nginx-1.10.0/html/TESTC/pravilo11.mp4" instead of "D:\video/TESTC/pravilo11.mp4". I tried to use "root D:\video;" and received the same error. Also I tried to use "alias" instead of "root", but I received the next error:

alias /video; -> "alias" cannot be used in location "/!/scorms.ecp/\d+(/.*\.(mp4|webm|ogv))$" where URI was rewritten

How can I tune nginx config for windows to find video file by the following path "D:\video/TESTC/pravilo11.mp4" instead of "D:\PAPISDK_4_T\nginx-1.10.0/html/TESTC/pravilo11.mp4"?

Cœur
  • 37,241
  • 25
  • 195
  • 267
sribin
  • 1,736
  • 1
  • 13
  • 21

0 Answers0