nginx.conf 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 80;
  19. server_name live.reghao.cn;
  20. rewrite ^(.*) https://$host permanent;
  21. }
  22. server {
  23. listen 443 ssl;
  24. server_name live.reghao.cn;
  25. ssl_certificate /data/ssl/reghao.cn/fullchain.cer;
  26. ssl_certificate_key /data/ssl/reghao.cn/reghao.cn.key;
  27. ssl_protocols TLSv1.2 TLSv1.3;
  28. ssl_ciphers HIGH:!aNULL:!MD5;
  29. ssl_prefer_server_ciphers on;
  30. ssl_session_cache shared:SSL:10m;
  31. ssl_session_timeout 10m;
  32. location /live {
  33. flv_live on; #打开 HTTP 播放 FLV 直播流功能
  34. chunked_transfer_encoding on; #支持 'Transfer-Encoding: chunked' 方式回复
  35. add_header 'Access-Control-Allow-Origin' '*'; #添加额外的 HTTP 头
  36. add_header 'Access-Control-Allow-Credentials' 'true'; #添加额外的 HTTP 头
  37. }
  38. location /hls {
  39. types {
  40. application/vnd.apple.mpegurl m3u8; ssl_protocols TLSv1.2 TLSv1.3;
  41. ssl_ciphers HIGH:!aNULL:!MD5;
  42. ssl_prefer_server_ciphers on;
  43. ssl_session_cache shared:SSL:10m;
  44. ssl_session_timeout 10m;
  45. video/mp2t ts;
  46. }
  47. root /tmp;
  48. add_header 'Cache-Control' 'no-cache';
  49. }
  50. location /dash {
  51. root /tmp;
  52. add_header 'Cache-Control' 'no-cache';
  53. }
  54. #如果需要 JSON 风格的 stat, 不用指定 stat.xsl
  55. #但是需要指定一个新的配置项 rtmp_stat_format
  56. location /stat {
  57. rtmp_stat all;
  58. rtmp_stat_format json;
  59. }
  60. location /control {
  61. rtmp_control all; #rtmp 控制模块的配置
  62. }
  63. location / {
  64. root /var/www;
  65. index index.html index.htm;
  66. }
  67. error_page 500 502 503 504 /50x.html;
  68. location = /50x.html {
  69. root html;
  70. }
  71. }
  72. }
  73. rtmp {
  74. # log_format rtmp_log_format '$remote_addr [$time_local] $command "$app" "$name" "$args" - $bytes_received bytes';
  75. # access_log /dev/stdout rtmp_log_format;
  76. server {
  77. listen 1935;
  78. chunk_size 4096;
  79. # /rtmp/cam201
  80. application rtmp {
  81. live on;
  82. gop_cache on; #打开 GOP 缓存,减少首屏等待时间
  83. record all;
  84. record_suffix _%Y%m%d_%H%M%S.flv;
  85. record_path /data/rtmp;
  86. record_max_size 1M; # 录制的单个 flv 文件最大值
  87. record_unique on;
  88. #on_publish https://auth.reghao.cn/api/auth/rtmp/on_publish;
  89. #on_publish_done https://auth.reghao.cn/api/auth/rtmp/on_publish_done;
  90. #on_play https://auth.reghao.cn/api/auth/rtmp/on_play;
  91. #on_play_done https://auth.reghao.cn/api/auth/rtmp/on_play_done;
  92. #on_record_done https://auth.reghao.cn/api/auth/rtmp/on_record_done;
  93. }
  94. application vod {
  95. live on;
  96. gop_cache on; #打开 GOP 缓存,减少首屏等待时间
  97. }
  98. application hls {
  99. live on;
  100. hls on;
  101. hls_path /tmp/hls;
  102. }
  103. application dash {
  104. live on;
  105. dash on;
  106. dash_path /tmp/dash;
  107. hls_fragment 10s;
  108. }
  109. }
  110. }