nginx.conf.template 2.4 KB
Newer Older
root's avatar
subdirs  
root committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
daemon off;

error_log /dev/stdout info;

events {
    worker_connections 1024;
}

rtmp {
    server {
        listen 1935;
        chunk_size 4000;

        application stream {
            live on;

hark's avatar
lala  
hark committed
17 18 19
            hls on;
            hls_fragment_naming system;
            hls_fragment 5;
hark's avatar
hark committed
20
            hls_playlist_length 10m;
hark's avatar
lala  
hark committed
21 22 23
            hls_path /opt/data/hls/stream;
            hls_nested on;

root's avatar
subdirs  
root committed
24 25 26 27 28 29 30 31
        }


        application hls {
            live on;
            hls on;
            hls_fragment_naming system;
            hls_fragment 5;
hark's avatar
lala  
hark committed
32 33
            hls_playlist_length 10m;

hark's avatar
lala  
hark committed
34
            hls_path /opt/data/hls/transcoded;
root's avatar
subdirs  
root committed
35 36
            hls_nested on;

dreamer's avatar
dreamer committed
37
            hls_variant _hi      BANDWIDTH=640000;
dreamer's avatar
dreamer committed
38
            hls_variant _low     BANDWIDTH=160000;
dreamer's avatar
dreamer committed
39
            hls_variant _audio   BANDWIDTH=500;
root's avatar
subdirs  
root committed
40
        }
hark's avatar
la  
hark committed
41 42

        
root's avatar
subdirs  
root committed
43 44 45 46 47 48 49 50 51 52 53
    }
}




http {
    access_log /dev/stdout combined;

    server {
        listen      80;
hark's avatar
la  
hark committed
54 55 56 57
        root /opt/data;
        autoindex on;
        

root's avatar
subdirs  
root committed
58

hark's avatar
shit  
hark committed
59 60
        if ($request_method = POST) {
            return 405;
hark's avatar
cache  
hark committed
61
        }
hark's avatar
shit  
hark committed
62 63 64 65 66 67 68 69 70

        location ~* .(m3u8)$ {
            add_header Cache-Control: public;
             add_header Cache-Control: max-age=20;
        }

        location ~* .(ts)$ {
            add_header Cache-Control: public;
             add_header Cache-Control: max-age=200;
hark's avatar
cache  
hark committed
71 72
        }

hark's avatar
hark committed
73 74 75 76
        #rewrite ^/$ http://${SD_HOST_HLS_CACHE}/player redirect;

        location /player {
          alias /www/player;
root's avatar
root committed
77 78
          autoindex on;

hark's avatar
hark committed
79 80
        }

dreamer's avatar
dreamer committed
81
        location /hls {
root's avatar
root committed
82 83
            autoindex on;

dreamer's avatar
dreamer committed
84 85 86 87
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
hark's avatar
lala  
hark committed
88
            alias /opt/data/hls;
dreamer's avatar
dreamer committed
89 90 91
            add_header Access-Control-Allow-Origin *;
        }

root's avatar
subdirs  
root committed
92
        location /live {
root's avatar
root committed
93 94
              autoindex on;

root's avatar
subdirs  
root committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108
          alias /opt/data/hls;
          types {
              application/vnd.apple.mpegurl m3u8;
              video/mp2t ts;
          }
          add_header Access-Control-Allow-Origin *;
        }

        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet static/stat.xsl;
        }

        location /static {
root's avatar
root committed
109 110 111
             autoindex on;


root's avatar
subdirs  
root committed
112 113 114
            alias /www/static;
        }

hark's avatar
brave  
hark committed
115
        location /brave {
root's avatar
root committed
116 117 118
   autoindex on;


hark's avatar
brave  
hark committed
119 120 121
            alias /www/brave;
        }

root's avatar
subdirs  
root committed
122 123 124 125 126 127 128
        location = /crossdomain.xml {
            root /www/static;
            default_type text/xml;
            expires 24h;
        }
    }
}