2
0

nginx.conf 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. http {
  2. # include mime.types;
  3. default_type application/octet-stream;
  4. types {
  5. text/plain txt;
  6. text/html html;
  7. text/css css;
  8. application/javascript js;
  9. application/vnd.apple.mpegurl m3u8;
  10. video/mp2t ts;
  11. application/rss+xml xml;
  12. }
  13. server {
  14. listen 1936;
  15. listen [::]:1936 ipv6only=on;
  16. set $cors '';
  17. if ($http_origin ~ '^https?\:\/\/(localhost(\:[\d+])?|\d+\.\d+\.\d+.\d+|(www\.)?ispooge\.com|(www\.)?harlanji\.com|(www\.)?tinydatacenter\.com)\/?') {
  18. set $cors 'C';
  19. }
  20. set $cors_opts '';
  21. if ($request_method = 'OPTIONS') {
  22. set $cors_opts "${cors}O";
  23. }
  24. location /hls/ {
  25. rewrite ^/hls/(.*) /$1 break;
  26. if ($cors = 'C') {
  27. add_header 'Access-Control-Allow-Origin' "$http_origin" always;
  28. add_header 'Access-Control-Allow-Credentials' 'true' always;
  29. add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
  30. add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
  31. # required to be able to read Authorization header in frontend
  32. #add_header 'Access-Control-Expose-Headers' 'Authorization' always;
  33. }
  34. if ($cors_opts = 'CO') {
  35. add_header 'Access-Control-Max-Age' 60;
  36. add_header 'Content-Type' 'text/plain charset=UTF-8';
  37. add_header 'Content-Length' 0;
  38. return 204;
  39. }
  40. root /tmp/http/hls/ispooge.com/;
  41. }
  42. # This URL provides RTMP statistics in XML
  43. location /hls/stat {
  44. rtmp_stat all;
  45. # Use this stylesheet to view XML as web page
  46. # in browser
  47. rtmp_stat_stylesheet stat.xsl;
  48. }
  49. location /media/ {
  50. rewrite ^/media/(.*) /$1 break;
  51. root /tmp/http/media/;
  52. }
  53. location / {
  54. if ($cors = 'C') {
  55. add_header 'Access-Control-Allow-Origin' "$http_origin" always;
  56. add_header 'Access-Control-Allow-Credentials' 'true' always;
  57. add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
  58. add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
  59. # required to be able to read Authorization header in frontend
  60. #add_header 'Access-Control-Expose-Headers' 'Authorization' always;
  61. }
  62. if ($cors_opts = 'CO') {
  63. add_header 'Access-Control-Max-Age' 60;
  64. add_header 'Content-Type' 'text/plain charset=UTF-8';
  65. add_header 'Content-Length' 0;
  66. return 204;
  67. }
  68. root /tmp/http/cryogen/;
  69. }
  70. }
  71. }
  72. worker_processes auto;
  73. rtmp_auto_push on;
  74. events {}
  75. rtmp {
  76. server {
  77. listen 1935;
  78. listen [::]:1935 ipv6only=on;
  79. chunk_size 4096;
  80. application participant {
  81. live on;
  82. }
  83. # monitor rtmp
  84. application record {
  85. live on;
  86. record all;
  87. record_path /tmp/rec;
  88. record_suffix _%Y-%m-%d_%H-%M-%S.flv;
  89. record_lock on;
  90. }
  91. application hls {
  92. live on;
  93. hls on;
  94. hls_path /tmp/http/hls/ispooge.com;
  95. #hls_base_url http://192.168.1.8:33080/hls/;
  96. hls_fragment 500ms;
  97. hls_playlist_length 3s;
  98. hls_fragment_naming_granularity 500;
  99. hls_continuous on;
  100. hls_nested on;
  101. hls_cleanup off;
  102. hls_fragment_naming system;
  103. hls_fragment_slicing aligned;
  104. hls_type live;
  105. hls_variant _720 BANDWIDTH=6491456 RESOLUTIO=1280x720;
  106. hls_variant _360 BANDWIDTH=3345728 RESOLUTION=640x360;
  107. hls_variant _240 BANDWIDTH=1248576 RESOLUTION=416x240;
  108. }
  109. application ispoogedaily_local {
  110. live on;
  111. push rtmp://127.0.0.1 app=hls live=1;
  112. }
  113. application ispoogedaily_source {
  114. live on;
  115. }
  116. application ispoogedaily_live {
  117. live on;
  118. #play_restart on;
  119. drop_idle_publisher 15s;
  120. #publish_notify on;
  121. wait_key on;
  122. wait_video on;
  123. # interleave on;
  124. #meta copy;
  125. # YT LIVE
  126. #push rtmp://a.rtmp.youtube.com app=live2 playpath=YT_KEY live=1;
  127. # Twitch
  128. #push rtmp://live-sjc.twitch.tv app=app playpath=TWITCH_KEY live=1;
  129. }
  130. }
  131. }