nginx.conf 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. user root;
  2. error_log /dev/stderr info;
  3. worker_processes 1;
  4. worker_rlimit_nofile 20000;
  5. events {
  6. use epoll;
  7. worker_connections 20000;
  8. multi_accept on;
  9. }
  10. http {
  11. include mime.types;
  12. default_type application/octet-stream;
  13. keepalive_timeout 60;
  14. server_tokens off;
  15. # HTTP 访问日志定向到标准输出
  16. access_log /dev/stdout;
  17. server {
  18. listen 8080;
  19. location /live {
  20. flv_live on; #打开 HTTP 播放 FLV 直播流功能
  21. chunked_transfer_encoding on; #支持 'Transfer-Encoding: chunked' 方式回复
  22. add_header 'Access-Control-Allow-Origin' '*'; #添加额外的 HTTP 头
  23. add_header 'Access-Control-Allow-Credentials' 'true'; #添加额外的 HTTP 头
  24. }
  25. location /hls {
  26. types {
  27. application/vnd.apple.mpegurl m3u8; ssl_protocols TLSv1.2 TLSv1.3;
  28. video/mp2t ts;
  29. }
  30. root /tmp;
  31. add_header 'Cache-Control' 'no-cache';
  32. }
  33. location /dash {
  34. root /tmp;
  35. add_header 'Cache-Control' 'no-cache';
  36. }
  37. #如果需要 JSON 风格的 stat, 不用指定 stat.xsl
  38. #但是需要指定一个新的配置项 rtmp_stat_format
  39. location /stat {
  40. rtmp_stat all;
  41. rtmp_stat_format json;
  42. }
  43. location /control {
  44. rtmp_control all; #rtmp 控制模块的配置
  45. }
  46. location / {
  47. root /var/www;
  48. index index.html index.htm;
  49. }
  50. error_page 500 502 503 504 /50x.html;
  51. location = /50x.html {
  52. root html;
  53. }
  54. }
  55. }
  56. rtmp {
  57. # log_format rtmp_log_format '$remote_addr [$time_local] $command "$app" "$name" "$args" - $bytes_received bytes';
  58. # access_log /dev/stdout rtmp_log_format;
  59. server {
  60. listen 1935;
  61. chunk_size 4096;
  62. # /rtmp/cam201
  63. application rtmp {
  64. live on;
  65. gop_cache on; #打开 GOP 缓存,减少首屏等待时间
  66. record all;
  67. record_suffix _%Y%m%d_%H%M%S.flv;
  68. record_path /data/rtmp;
  69. record_max_size 1M; # 录制的单个 flv 文件最大值
  70. record_unique on;
  71. #on_publish https://auth.reghao.cn/api/auth/rtmp/on_publish;
  72. #on_publish_done https://auth.reghao.cn/api/auth/rtmp/on_publish_done;
  73. #on_play https://auth.reghao.cn/api/auth/rtmp/on_play;
  74. #on_play_done https://auth.reghao.cn/api/auth/rtmp/on_play_done;
  75. #on_record_done https://auth.reghao.cn/api/auth/rtmp/on_record_done;
  76. }
  77. application vod {
  78. live on;
  79. gop_cache on; #打开 GOP 缓存,减少首屏等待时间
  80. }
  81. application hls {
  82. live on;
  83. hls on;
  84. hls_path /tmp/hls;
  85. }
  86. application dash {
  87. live on;
  88. dash on;
  89. dash_path /tmp/dash;
  90. hls_fragment 10s;
  91. }
  92. }
  93. }