2
0

nginx.conf 4.7 KB

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