This example is part of this article.
This is an example for an HLS delivery with basic security. Nginx compiled with nginx-rtmp-module & secure-link is used as media server. Features:
- Domain filtering
- Referrer filtering
- Embed buster
<!DOCTYPE html> | |
<html lang='`en'> | |
<head> | |
<meta charset='utf-8'/> | |
<title>Audio only stream example</title> | |
<script src="//cdn.jsdelivr.net/npm/hls.js@latest"></script> | |
<style> | |
video { | |
width: 640px; | |
height: 360px; |
This example is part of this article.
This is an example for an HLS delivery with basic security. Nginx compiled with nginx-rtmp-module & secure-link is used as media server. Features:
<video controls="" width="400"> | |
<source src="http://66.128.61.175/reel/1cc976948e74aa62f7a7fde16e64fb6b/360p" type="video/mp4"> | |
Your browser does not support HTML5 video. | |
</video> |
$ ffmpeg -r 5 -i <INPUT_VIDEO> -map 0 -vcodec libx264 -f segment -segment_list out.m3u8 | |
\ -segment_time 10 -segment_list_flags +live -segment_wrap 32 out%02d.ts | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<script src="https://cdn.jsdelivr.net/hls.js/latest/hls.min.js"></script> |
# Nginx config example | |
``` | |
location /asset { | |
secure_link $arg_md5,$arg_expires; | |
secure_link_md5 "secret$uri$arg_expires"; | |
if ($secure_link = "") { | |
return 403; | |
} |
<?php | |
/** | |
* @param $baseUrl - non protected part of the URL including hostname, e.g. http://example.com | |
* @param $path - protected path to the file, e.g. /downloads/myfile.zip | |
* @param $secret - the shared secret with the nginx server. Keep this info secure!!! | |
* @param $ttl - the number of seconds until this link expires | |
* @param $userIp - ip of the user allowed to download | |
* @return string | |
*/ |
# to generate your dhparam.pem file, run in the terminal | |
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
#!/usr/bin/ruby | |
# -*- encoding: UTF-8 -*- | |
# AUDIO_CODEC=" -acodec copy -absf aac_adtstoasc" | |
AUDIO_CODEC=" -acodec libfaac -aq 110" | |
acodec = AUDIO_CODEC | |
file = File::expand_path( ARGV[0] ) | |
out = ARGV[1] | |
exit 1 unless File.exist?(file) |
# Nginx can serve FLV/MP4 files by pseudo-streaming way without any specific media-server software. | |
# To do the custom build we use 2 modules: --with-http_secure_link_module --with-http_flv_module | |
# This module "secure-link" helps you to protect links from stealing away. | |
# | |
# NOTE: see more details at coderwall: http://coderwall.com/p/3hksyg | |
cd /usr/src | |
wget http://nginx.org/download/nginx-1.5.13.tar.gz | |
tar xzvf ./nginx-1.5.13.tar.gz && rm -f ./nginx-1.5.13.tar.gz |