nginx.conf 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. worker_processes 1;
  2. error_log /var/log/nginx/error.log warn;
  3. pid /var/run/nginx.pid;
  4. load_module "modules/ngx_rtmp_module.so";
  5. events {
  6. worker_connections 1024;
  7. }
  8. http {
  9. include /etc/nginx/mime.types;
  10. default_type application/octet-stream;
  11. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  12. '$status $body_bytes_sent "$http_referer" '
  13. '"$http_user_agent" "$http_x_forwarded_for"';
  14. access_log /var/log/nginx/access.log main;
  15. sendfile on;
  16. keepalive_timeout 65;
  17. upstream frigate_api {
  18. server localhost:5001;
  19. keepalive 1024;
  20. }
  21. server {
  22. listen 5000;
  23. location /stream/ {
  24. add_header 'Cache-Control' 'no-cache';
  25. add_header 'Access-Control-Allow-Origin' "$http_origin" always;
  26. add_header 'Access-Control-Allow-Credentials' 'true';
  27. add_header 'Access-Control-Expose-Headers' 'Content-Length';
  28. if ($request_method = 'OPTIONS') {
  29. add_header 'Access-Control-Allow-Origin' "$http_origin";
  30. add_header 'Access-Control-Max-Age' 1728000;
  31. add_header 'Content-Type' 'text/plain charset=UTF-8';
  32. add_header 'Content-Length' 0;
  33. return 204;
  34. }
  35. types {
  36. application/dash+xml mpd;
  37. application/vnd.apple.mpegurl m3u8;
  38. video/mp2t ts;
  39. image/jpeg jpg;
  40. }
  41. root /tmp;
  42. }
  43. location /clips/ {
  44. add_header 'Access-Control-Allow-Origin' "$http_origin" always;
  45. add_header 'Access-Control-Allow-Credentials' 'true';
  46. add_header 'Access-Control-Expose-Headers' 'Content-Length';
  47. if ($request_method = 'OPTIONS') {
  48. add_header 'Access-Control-Allow-Origin' "$http_origin";
  49. add_header 'Access-Control-Max-Age' 1728000;
  50. add_header 'Content-Type' 'text/plain charset=UTF-8';
  51. add_header 'Content-Length' 0;
  52. return 204;
  53. }
  54. types {
  55. video/mp4 mp4;
  56. image/jpeg jpg;
  57. }
  58. autoindex on;
  59. root /media/frigate;
  60. }
  61. location /recordings/ {
  62. add_header 'Access-Control-Allow-Origin' "$http_origin" always;
  63. add_header 'Access-Control-Allow-Credentials' 'true';
  64. add_header 'Access-Control-Expose-Headers' 'Content-Length';
  65. if ($request_method = 'OPTIONS') {
  66. add_header 'Access-Control-Allow-Origin' "$http_origin";
  67. add_header 'Access-Control-Max-Age' 1728000;
  68. add_header 'Content-Type' 'text/plain charset=UTF-8';
  69. add_header 'Content-Length' 0;
  70. return 204;
  71. }
  72. types {
  73. video/mp4 mp4;
  74. }
  75. autoindex on;
  76. autoindex_format json;
  77. root /media/frigate;
  78. }
  79. location /api/ {
  80. add_header 'Access-Control-Allow-Origin' '*';
  81. proxy_pass http://frigate_api/;
  82. proxy_pass_request_headers on;
  83. proxy_set_header Host $host;
  84. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  85. proxy_set_header X-Forwarded-Proto $scheme;
  86. }
  87. location / {
  88. root /opt/frigate/web;
  89. try_files $uri $uri/ /index.html;
  90. }
  91. }
  92. }
  93. rtmp {
  94. server {
  95. listen 1935;
  96. chunk_size 4096;
  97. allow publish 127.0.0.1;
  98. deny publish all;
  99. allow play all;
  100. application live {
  101. live on;
  102. record off;
  103. meta copy;
  104. }
  105. }
  106. }