Open erdi2202 opened 2 years ago
kaltura.conf file
`# static files (crossdomain.xml, robots.txt etc.) + fallback to api location / { root @STATIC_FILES_PATH@; try_files $uri @api_fallback; }
location /nginx_status { stub_status on; access_log off; }
location /vod_status { vod_status; access_log off; }
location /kalapi_proxy/ { internal; proxy_pass http://kalapi/; proxy_set_header Host $http_host; }
location ~ ^/p/\d+/(sp/\d+/)?serveFlavor/((?!clipFrom)(?!clipTo).)*$ { vod none;
add_header Last-Modified "Sun, 19 Nov 2000 08:52:00 GMT";
expires 100d;
}
location /hls/p/\d+/(sp/\d+/)?serveFlavor/ { vod hls; vod_bootstrap_segment_durations 2000; vod_bootstrap_segment_durations 2000; vod_bootstrap_segment_durations 2000; vod_bootstrap_segment_durations 4000;
add_header Last-Modified "Sun, 19 Nov 2000 08:52:00 GMT";
add_header Access-Control-Allow-Headers "*";
add_header Access-Control-Expose-Headers "Server,range,Content-Length,Content-Range";
add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS";
add_header Access-Control-Allow-Origin "*";
expires 100d;
}
location ~ ^/dash/p/\d+/(sp/\d+/)?serveFlavor/ { vod dash; vod_segment_duration 4000; vod_bootstrap_segment_durations 3500; vod_align_segments_to_key_frames on; vod_dash_manifest_format segmenttemplate;
add_header Last-Modified "Sun, 19 Nov 2000 08:52:00 GMT";
add_header Access-Control-Allow-Headers "origin,range,accept-encoding,referer";
add_header Access-Control-Expose-Headers "Server,range,Content-Length,Content-Range";
add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS";
add_header Access-Control-Allow-Origin "*";
expires 100d;
}
location ~ ^/hds/p/\d+/(sp/\d+/)?serveFlavor/ { vod hds; vod_segment_duration 6000; vod_align_segments_to_key_frames on; vod_segment_count_policy last_rounded;
add_header Last-Modified "Sun, 19 Nov 2000 08:52:00 GMT";
add_header Access-Control-Allow-Origin "*";
expires 100d;
}
location ~ ^/mss/p/\d+/(sp/\d+/)?serveFlavor/ { vod mss; vod_segment_duration 4000; vod_manifest_segment_durations_mode accurate;
add_header Last-Modified "Sun, 19 Nov 2000 08:52:00 GMT";
expires 100d;
}
location @api_fallback { proxy_pass http://kalapi; proxy_set_header Host $http_host; }
# error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }
location /dashme {
open_file_cache off;
root /var/tmp;
add_header Cache-Control no-cache;
# To avoid issues with cross-domain HTTP requests (e.g. during development)
add_header Access-Control-Allow-Origin *;
}
location /hlsme {
open_file_cache off;
types {
application/vnd.apple.mpegurl m3u8;
}
root /var/tmp;
add_header Cache-Control no-cache; # Prevent caching of HLS fragments
add_header Access-Control-Allow-Origin *; # Allow web player to access our playlist
}`
And it doesn't work when I try with load balancer url like this. http://2.rectvideo.tk/hls/d1/cdn4/movies/hd/mp4/12yillik.mp4/index.m3u8
Sorry, but I can't really understand what you wrote...
I'm telling you in detail what I want to do.
I have 3 vod servers. d11.rectvideo.tk, d12.rectvideo.tk, d13.rectvideo.tk and these servers' nginx conf files are like this:
server { listen 95.217.190.50:80; server_name d11.rectvideo.tk www.d11.rectvideo.tk; error_log /var/log/apache2/domains/d11.rectvideo.tk.error.log error;
# vod settings
vod_mode local;
vod_last_modified 'Sun, 19 Nov 2000 08:52:00 GMT';
vod_last_modified_types *;
vod_segment_duration 3000;
# vod caches
vod_metadata_cache metadata_cache 512m;
vod_response_cache response_cache 128m;
vod_mapping_cache mapping_cache 5m;
# gzip manifests
gzip on;
gzip_types application/vnd.apple.mpegurl;
# file handle caching / aio
open_file_cache max=1000 inactive=5m;
open_file_cache_valid 2m;
open_file_cache_min_uses 1;
open_file_cache_errors on;
aio on;
location / {
proxy_pass http://95.217.190.50:8080;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|exe|iso|dmg|swf)$ {
root /storage;
access_log /var/log/apache2/domains/d11.rectvideo.tk.log combined;
access_log /var/log/apache2/domains/d11.rectvideo.tk.bytes bytes;
expires max;
try_files $uri @fallback;
}
}
location /error/ {
alias /home/admin/web/d11.rectvideo.tk/document_errors/;
}
location @fallback {
proxy_pass http://95.217.190.50:8080;
}
location /hls/ {
sub_filter .ts .ts$is_args$args;
sub_filter_once off;
sub_filter_types application/vnd.apple.mpegurl;
secure_link $arg_token,$arg_tms;
secure_link_md5 rmzn$arg_tms$remote_addr;
if ($secure_link = "") {
return 403;
}
if ($secure_link = "0") {
return 410;
}
vod hls;
vod_segment_duration 3000;
alias /storage/;
add_header Access-Control-Allow-Headers '*';
add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range';
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
add_header Access-Control-Allow-Origin '*';
expires 100d;
}
location /mp4/ {
sub_filter .mp4 .mp4$is_args$args;
sub_filter_once off;
sub_filter_types application/vnd.apple.mpegurl;
secure_link $arg_token,$arg_tms;
secure_link_md5 rmzn$arg_tms$remote_addr;
if ($secure_link = "") {
return 403;
}
if ($secure_link = "0") {
return 410;
}
vod none;
alias /storage/;
}
# vod status page
location /vod_status {
vod_status;
access_log off;
}
location ~ .(mp4)$ { sub_filter .mp4 .mp4$is_args$args; sub_filter_once off; sub_filter_types application/vnd.apple.mpegurl; secure_link $arg_token,$arg_tms; secure_link_md5 rmzn$arg_tms$remote_addr;
if ($secure_link = "") {
return 403;
}
if ($secure_link = "0") {
return 410;
}
root /storage;
expires max;
try_files $uri @fallback;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include /home/admin/conf/web/nginx.d11.rectvideo.tk.conf*;
}
hls runs smoothly and plays videos on direct vod servers.
I installed a load balancer server and set the conf file like this :
user kaltura; worker_processes auto;
pid /var/run/nginx.pid;
events { worker_connections 1024; multi_accept on; use epoll; }
http { upstream kalapi { server d11.rectvideo.tk:80; server d12.rectvideo.tk:80; server d13.rectvideo.tk:80;
}
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $bytes_sent $request_time "$http_referer" "$http_user_agent" "-" - '
'"$sent_http_x_kaltura" "$http_host" $pid $sent_http_x_kaltura_session - '
'$request_length "$sent_http_content_range" "$http_x_forwarded_for" '
'"$http_x_forwarded_server" "$http_x_forwarded_host" "$sent_http_cache_control" '
'$connection ';
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60;
keepalive_requests 1000;
client_header_timeout 20;
client_body_timeout 20;
reset_timedout_connection on;
send_timeout 20;
vod_mode remote;
vod_upstream_location /kalapi;
vod_last_modified 'Sun, 19 Nov 2000 08:52:00 GMT';
vod_last_modified_types *;
# vod caches
vod_metadata_cache metadata_cache 512m;
vod_response_cache response_cache 128m;
# gzip manifests
gzip on;
gzip_types application/vnd.apple.mpegurl;
server {
listen 80;
server_name 2.rectvideo.tk;
include /etc/nginx/conf.d/kaltura.conf;
location ^~ /kalapi/ {
internal;
proxy_pass http://kalapi/;
proxy_set_header Host d11.rectvideo.tk; # Has to be set in order to work
}
}
}
and kaltura.conf
# static files (crossdomain.xml, robots.txt etc.) + fallback to api
location / {
root @STATIC_FILES_PATH@;
try_files $uri @api_fallback;
}
# nginx status page
location /nginx_status {
stub_status on;
access_log off;
}
# vod status page
location /vod_status {
vod_status;
access_log off;
}
# internal location for vod subrequests
location /kalapi_proxy/ {
internal;
proxy_pass http://kalapi/;
proxy_set_header Host $http_host;
}
# serve flavor progressive (clipFrom/To are not supported with 'vod none' so they are proxied)
location ~ ^/p/\d+/(sp/\d+/)?serveFlavor/((?!clipFrom)(?!clipTo).)*$ {
vod none;
add_header Last-Modified "Sun, 19 Nov 2000 08:52:00 GMT";
expires 100d;
}
location /hls/ {
vod_mode remote;
vod_upstream_location /storage;
vod hls;
gzip on;
gzip_types application/x-mpegURL;
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range';
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
add_header Access-Control-Allow-Origin '*';
}
# all unidentified requests fallback to api (inc. playManifest)
location @api_fallback {
proxy_pass http://kalapi;
proxy_set_header Host $http_host;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /hlsme {
open_file_cache off;
types {
application/vnd.apple.mpegurl m3u8;
}
root /var/tmp;
add_header Cache-Control no-cache; # Prevent caching of HLS fragments
add_header Access-Control-Allow-Origin *; # Allow web player to access our playlist
}
Now when I call the load balancer domain, it connects to vod servers. http://2.rectvideo.tk but when I call hls with load balancer, vod server gives 404 error. http://2.rectvideo.tk/hls/d1/cdn4/movies/hd/mp4/12yillik.mp4/index.m3u8?token=BWLK172vum9hCmuA2v3Q9A&tms=1644566673
- Would be nice to escape the config with 3 backticks, so that it will be readable...
- I don't see any location for /hls, only /hlsme
- The /hlsme location just serves file, it doesn't invoke this module, so not sure what you were expecting
If the upstream server is already doing the HLS segmentation (and from what you wrote, I understand this part is working), the load balancer should not use this module, you just need a simple nginx config that does proxy_pass. You can google for nginx load balancer configs, there are probably a lot of samples out there, it has nothing to do with this module...
If the upstream server is already doing the HLS segmentation (and from what you wrote, I understand this part is working), the load balancer should not use this module, you just need a simple nginx config that does proxy_pass. You can google for nginx load balancer configs, there are probably a lot of samples out there, it has nothing to do with this module...
Yes, I tried that too, but it still only works as mp4. When I try to play hls with my load balancer server, it gives 404 error.
balancer.rectvideo.tk nginx.conf
` upstream backend { server 95.217.190.50; server 95.217.176.134; server 95.217.177.154; }
server { listen 95.217.132.184:80; server_name balancer.rectvideo.tk www.balancer.rectvideo.tk; error_log /var/log/apache2/domains/balancer.rectvideo.tk.error.log error;
location / { proxy_pass http://backend; location ~* ^.+.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|exe|iso|dmg|swf)$ { root /storage; access_log /var/log/apache2/domains/balancer.rectvideo.tk.log combined; access_log /var/log/apache2/domains/balancer.rectvideo.tk.bytes bytes; expires max; try_files $uri @fallback;
}
}
location /error/ {
alias /home/admin/web/balancer.rectvideo.tk/document_errors/;
}
location @fallback {
proxy_pass http://95.217.132.184:8080;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include /home/admin/conf/web/nginx.balancer.rectvideo.tk.conf*;
}
`
hls not working:
but mp4 works:
hls
mp4
Hello, I am trying to play hls videos on my storage server with the kaltura remote module, but I could not succeed. When I run the Kaltura vod module locally on the storage server, the url = http://d11.rectvideo.tk/hls/d1/cdn4/movies/hd/mp4/12yillik.mp4/index.m3u8 and it works fine. But with my load balancer server
upstream kalapi { server 95.217.190.50; server 95.217.176.134; server 95.217.177.154; }
In this way, when I connect to storage servers, it works as mp4 but not as hls.
nginx.conf file
`user kaltura; worker_processes auto;
pid /var/run/nginx.pid;
events { worker_connections 1024; multi_accept on; use epoll; }
http { upstream kalapi { server d11.rectvideo.tk:80; } include mime.types; default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $bytes_sent $request_time "$http_referer" "$http_user_agent" "-" - ' '"$sent_http_x_kaltura" "$http_host" $pid $sent_http_x_kaltura_session - ' '$request_length "$sent_http_content_range" "$http_x_forwarded_for" ' '"$http_x_forwarded_server" "$http_x_forwarded_host" "$sent_http_cache_control" ' '$connection ';
sendfile on; tcp_nopush on; tcp_nodelay on;
keepalive_timeout 60; keepalive_requests 1000; client_header_timeout 20; client_body_timeout 20; reset_timedout_connection on; send_timeout 20;
server { listen 80; server_name 2.rectvideo.tk; include /etc/nginx/conf.d/kaltura.conf;
}user kaltura; worker_processes auto;
pid /var/run/nginx.pid;
events { worker_connections 1024; multi_accept on; use epoll; }
http { upstream kalapi { server d11.rectvideo.tk:80; } include mime.types; default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $bytes_sent $request_time "$http_referer" "$http_user_agent" "-" - ' '"$sent_http_x_kaltura" "$http_host" $pid $sent_http_x_kaltura_session - ' '$request_length "$sent_http_content_range" "$http_x_forwarded_for" ' '"$http_x_forwarded_server" "$http_x_forwarded_host" "$sent_http_cache_control" ' '$connection ';
sendfile on; tcp_nopush on; tcp_nodelay on;
keepalive_timeout 60; keepalive_requests 1000; client_header_timeout 20; client_body_timeout 20; reset_timedout_connection on; send_timeout 20;
server { listen 80; server_name 2.rectvideo.tk; include /etc/nginx/conf.d/kaltura.conf;
}`