2021-03-03 14:33:50 +01:00
|
|
|
daemon off;
|
2021-09-21 02:02:59 +02:00
|
|
|
user root;
|
2022-12-18 00:53:34 +01:00
|
|
|
worker_processes auto;
|
2020-11-02 12:44:16 +01:00
|
|
|
|
2022-12-18 00:53:34 +01:00
|
|
|
error_log /dev/stdout warn;
|
|
|
|
pid /var/run/nginx.pid;
|
2020-11-02 12:44:16 +01:00
|
|
|
|
|
|
|
events {
|
2022-12-18 00:53:34 +01:00
|
|
|
worker_connections 1024;
|
2020-11-02 12:44:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
http {
|
2024-01-31 12:53:59 +01:00
|
|
|
map_hash_bucket_size 256;
|
|
|
|
|
2022-12-18 00:53:34 +01:00
|
|
|
include mime.types;
|
|
|
|
default_type application/octet-stream;
|
2020-11-02 12:44:16 +01:00
|
|
|
|
2022-12-18 00:53:34 +01:00
|
|
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
2020-11-02 12:44:16 +01:00
|
|
|
'$status $body_bytes_sent "$http_referer" '
|
|
|
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
|
|
|
2022-12-18 00:53:34 +01:00
|
|
|
access_log /dev/stdout main;
|
2020-11-02 12:44:16 +01:00
|
|
|
|
2022-12-18 00:53:34 +01:00
|
|
|
# send headers in one piece, it is better than sending them one by one
|
|
|
|
tcp_nopush on;
|
2020-11-02 12:44:16 +01:00
|
|
|
|
2022-12-18 00:53:34 +01:00
|
|
|
sendfile on;
|
|
|
|
|
|
|
|
keepalive_timeout 65;
|
2020-11-02 12:44:16 +01:00
|
|
|
|
2021-01-29 06:04:52 +01:00
|
|
|
gzip on;
|
|
|
|
gzip_comp_level 6;
|
|
|
|
gzip_types text/plain text/css application/json application/x-javascript application/javascript text/javascript image/svg+xml image/x-icon image/bmp image/png image/gif image/jpeg image/jpg;
|
|
|
|
gzip_proxied no-cache no-store private expired auth;
|
|
|
|
gzip_vary on;
|
|
|
|
|
2023-10-29 12:47:24 +01:00
|
|
|
proxy_cache_path /dev/shm/nginx_cache levels=1:2 keys_zone=api_cache:10m max_size=10m inactive=1m use_temp_path=off;
|
|
|
|
|
2023-11-09 23:09:25 +01:00
|
|
|
map $sent_http_content_type $should_not_cache {
|
2023-11-08 00:18:58 +01:00
|
|
|
'application/json' 0;
|
|
|
|
default 1;
|
|
|
|
}
|
|
|
|
|
2020-11-08 23:35:21 +01:00
|
|
|
upstream frigate_api {
|
2022-12-18 00:53:34 +01:00
|
|
|
server 127.0.0.1:5001;
|
|
|
|
keepalive 1024;
|
2020-11-08 23:35:21 +01:00
|
|
|
}
|
2020-11-02 12:44:16 +01:00
|
|
|
|
2021-06-14 14:31:13 +02:00
|
|
|
upstream mqtt_ws {
|
2022-12-18 00:53:34 +01:00
|
|
|
server 127.0.0.1:5002;
|
|
|
|
keepalive 1024;
|
2021-06-14 14:31:13 +02:00
|
|
|
}
|
|
|
|
|
2021-03-02 13:54:12 +01:00
|
|
|
upstream jsmpeg {
|
2022-12-18 00:53:34 +01:00
|
|
|
server 127.0.0.1:8082;
|
|
|
|
keepalive 1024;
|
2021-03-02 13:54:12 +01:00
|
|
|
}
|
|
|
|
|
2024-06-01 17:29:46 +02:00
|
|
|
include go2rtc_upstream.conf;
|
|
|
|
|
|
|
|
server {
|
2024-06-02 14:48:28 +02:00
|
|
|
include listen.conf;
|
2024-06-01 17:29:46 +02:00
|
|
|
|
2021-05-18 07:52:08 +02:00
|
|
|
# vod settings
|
2021-06-03 18:17:08 +02:00
|
|
|
vod_base_url '';
|
|
|
|
vod_segments_base_url '';
|
2021-05-18 07:52:08 +02:00
|
|
|
vod_mode mapped;
|
|
|
|
vod_max_mapping_response_size 1m;
|
|
|
|
vod_upstream_location /api;
|
2021-08-29 04:26:23 +02:00
|
|
|
vod_align_segments_to_key_frames on;
|
|
|
|
vod_manifest_segment_durations_mode accurate;
|
2022-08-26 13:33:16 +02:00
|
|
|
vod_ignore_edit_list on;
|
2022-12-18 00:53:34 +01:00
|
|
|
vod_segment_duration 10000;
|
|
|
|
vod_hls_mpegts_align_frames off;
|
|
|
|
vod_hls_mpegts_interleave_frames on;
|
|
|
|
|
|
|
|
# file handle caching / aio
|
|
|
|
open_file_cache max=1000 inactive=5m;
|
|
|
|
open_file_cache_valid 2m;
|
|
|
|
open_file_cache_min_uses 1;
|
|
|
|
open_file_cache_errors on;
|
|
|
|
aio on;
|
|
|
|
|
|
|
|
# https://github.com/kaltura/nginx-vod-module#vod_open_file_thread_pool
|
|
|
|
vod_open_file_thread_pool default;
|
2021-05-18 07:52:08 +02:00
|
|
|
|
|
|
|
# vod caches
|
|
|
|
vod_metadata_cache metadata_cache 512m;
|
2021-12-12 15:03:38 +01:00
|
|
|
vod_mapping_cache mapping_cache 5m 10m;
|
2021-05-18 07:52:08 +02:00
|
|
|
|
|
|
|
# gzip manifests
|
|
|
|
gzip on;
|
|
|
|
gzip_types application/vnd.apple.mpegurl;
|
|
|
|
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_location.conf;
|
|
|
|
|
2021-05-18 07:52:08 +02:00
|
|
|
location /vod/ {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2022-12-18 00:53:34 +01:00
|
|
|
aio threads;
|
2021-05-18 07:52:08 +02:00
|
|
|
vod hls;
|
|
|
|
|
2021-07-13 03:54:12 +02:00
|
|
|
secure_token $args;
|
2022-12-18 00:53:34 +01:00
|
|
|
secure_token_types application/vnd.apple.mpegurl;
|
2021-07-13 03:54:12 +02:00
|
|
|
|
2022-04-25 15:00:01 +02:00
|
|
|
add_header Cache-Control "no-store";
|
|
|
|
expires off;
|
2021-05-18 07:52:08 +02:00
|
|
|
}
|
|
|
|
|
2020-11-02 12:44:16 +01:00
|
|
|
location /stream/ {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2022-04-25 15:00:01 +02:00
|
|
|
add_header Cache-Control "no-store";
|
|
|
|
expires off;
|
2020-11-02 12:44:16 +01:00
|
|
|
|
|
|
|
types {
|
|
|
|
application/dash+xml mpd;
|
|
|
|
application/vnd.apple.mpegurl m3u8;
|
|
|
|
video/mp2t ts;
|
|
|
|
image/jpeg jpg;
|
|
|
|
}
|
|
|
|
|
|
|
|
root /tmp;
|
|
|
|
}
|
|
|
|
|
2020-11-08 23:35:21 +01:00
|
|
|
location /clips/ {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2020-11-02 12:44:16 +01:00
|
|
|
types {
|
|
|
|
video/mp4 mp4;
|
|
|
|
image/jpeg jpg;
|
|
|
|
}
|
|
|
|
|
2024-06-09 20:45:26 +02:00
|
|
|
expires 7d;
|
|
|
|
add_header Cache-Control "public";
|
2020-11-02 12:44:16 +01:00
|
|
|
autoindex on;
|
2020-11-08 23:35:21 +01:00
|
|
|
root /media/frigate;
|
|
|
|
}
|
|
|
|
|
2021-08-10 15:27:31 +02:00
|
|
|
location /cache/ {
|
2022-12-18 00:53:34 +01:00
|
|
|
internal; # This tells nginx it's not accessible from the outside
|
|
|
|
alias /tmp/cache/;
|
2021-08-10 15:27:31 +02:00
|
|
|
}
|
|
|
|
|
2020-11-30 14:56:19 +01:00
|
|
|
location /recordings/ {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2023-06-08 13:32:35 +02:00
|
|
|
types {
|
|
|
|
video/mp4 mp4;
|
|
|
|
}
|
|
|
|
|
|
|
|
autoindex on;
|
|
|
|
autoindex_format json;
|
|
|
|
root /media/frigate;
|
|
|
|
}
|
|
|
|
|
|
|
|
location /exports/ {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2020-11-30 14:56:19 +01:00
|
|
|
types {
|
|
|
|
video/mp4 mp4;
|
|
|
|
}
|
|
|
|
|
|
|
|
autoindex on;
|
|
|
|
autoindex_format json;
|
|
|
|
root /media/frigate;
|
|
|
|
}
|
|
|
|
|
2021-02-13 15:09:44 +01:00
|
|
|
location /ws {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2021-06-14 14:31:13 +02:00
|
|
|
proxy_pass http://mqtt_ws/;
|
2023-10-21 15:15:24 +02:00
|
|
|
include proxy.conf;
|
2021-02-13 15:09:44 +01:00
|
|
|
}
|
|
|
|
|
2022-11-02 12:36:09 +01:00
|
|
|
location /live/jsmpeg/ {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2021-03-02 13:54:12 +01:00
|
|
|
proxy_pass http://jsmpeg/;
|
2023-10-21 15:15:24 +02:00
|
|
|
include proxy.conf;
|
2021-03-02 13:54:12 +01:00
|
|
|
}
|
|
|
|
|
2023-11-28 01:25:47 +01:00
|
|
|
# frigate lovelace card uses this path
|
|
|
|
location /live/mse/api/ws {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2023-11-28 01:25:47 +01:00
|
|
|
limit_except GET {
|
|
|
|
deny all;
|
|
|
|
}
|
|
|
|
proxy_pass http://go2rtc/api/ws;
|
2023-10-21 15:15:24 +02:00
|
|
|
include proxy.conf;
|
2022-11-02 12:36:09 +01:00
|
|
|
}
|
|
|
|
|
2023-11-28 01:25:47 +01:00
|
|
|
location /live/webrtc/api/ws {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2023-11-28 01:25:47 +01:00
|
|
|
limit_except GET {
|
|
|
|
deny all;
|
|
|
|
}
|
|
|
|
proxy_pass http://go2rtc/api/ws;
|
2023-10-21 15:15:24 +02:00
|
|
|
include proxy.conf;
|
2022-11-02 12:36:09 +01:00
|
|
|
}
|
|
|
|
|
2023-11-28 01:25:47 +01:00
|
|
|
# pass through go2rtc player
|
|
|
|
location /live/webrtc/webrtc.html {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2023-11-28 01:25:47 +01:00
|
|
|
limit_except GET {
|
|
|
|
deny all;
|
|
|
|
}
|
|
|
|
proxy_pass http://go2rtc/webrtc.html;
|
|
|
|
include proxy.conf;
|
|
|
|
}
|
|
|
|
|
|
|
|
# frontend uses this to fetch the version
|
|
|
|
location /api/go2rtc/api {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2023-11-28 01:25:47 +01:00
|
|
|
limit_except GET {
|
|
|
|
deny all;
|
|
|
|
}
|
|
|
|
proxy_pass http://go2rtc/api;
|
2023-10-21 15:15:24 +02:00
|
|
|
include proxy.conf;
|
2023-05-05 04:04:06 +02:00
|
|
|
}
|
|
|
|
|
2023-12-01 14:47:09 +01:00
|
|
|
# integration uses this to add webrtc candidate
|
|
|
|
location /api/go2rtc/webrtc {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2023-12-01 14:47:09 +01:00
|
|
|
limit_except POST {
|
|
|
|
deny all;
|
|
|
|
}
|
|
|
|
proxy_pass http://go2rtc/api/webrtc;
|
|
|
|
include proxy.conf;
|
|
|
|
}
|
|
|
|
|
2024-03-13 00:19:16 +01:00
|
|
|
location ~* /api/.*\.(jpg|jpeg|png|webp|gif)$ {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2022-08-25 14:32:30 +02:00
|
|
|
rewrite ^/api/(.*)$ $1 break;
|
|
|
|
proxy_pass http://frigate_api;
|
2023-10-21 15:15:24 +02:00
|
|
|
include proxy.conf;
|
2022-04-25 15:00:01 +02:00
|
|
|
}
|
|
|
|
|
2021-01-09 18:26:46 +01:00
|
|
|
location /api/ {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2022-04-25 15:00:01 +02:00
|
|
|
add_header Cache-Control "no-store";
|
|
|
|
expires off;
|
2020-11-08 23:35:21 +01:00
|
|
|
proxy_pass http://frigate_api/;
|
2023-10-21 15:15:24 +02:00
|
|
|
include proxy.conf;
|
|
|
|
|
2023-10-29 12:47:24 +01:00
|
|
|
proxy_cache api_cache;
|
|
|
|
proxy_cache_lock on;
|
|
|
|
proxy_cache_use_stale updating;
|
|
|
|
proxy_cache_valid 200 5s;
|
|
|
|
proxy_cache_bypass $http_x_cache_bypass;
|
2023-11-08 00:18:58 +01:00
|
|
|
proxy_no_cache $should_not_cache;
|
2023-10-29 12:47:24 +01:00
|
|
|
add_header X-Cache-Status $upstream_cache_status;
|
|
|
|
|
|
|
|
location /api/vod/ {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2023-10-29 12:47:24 +01:00
|
|
|
proxy_pass http://frigate_api/vod/;
|
|
|
|
include proxy.conf;
|
|
|
|
proxy_cache off;
|
|
|
|
}
|
|
|
|
|
2024-05-18 18:36:13 +02:00
|
|
|
location /api/login {
|
|
|
|
auth_request off;
|
|
|
|
rewrite ^/api(/.*)$ $1 break;
|
|
|
|
proxy_pass http://frigate_api;
|
|
|
|
include proxy.conf;
|
|
|
|
}
|
|
|
|
|
2023-10-21 15:15:24 +02:00
|
|
|
location /api/stats {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2023-10-21 15:15:24 +02:00
|
|
|
access_log off;
|
2024-04-11 13:41:07 +02:00
|
|
|
rewrite ^/api(/.*)$ $1 break;
|
2023-10-21 17:40:46 +02:00
|
|
|
proxy_pass http://frigate_api;
|
2023-10-21 15:15:24 +02:00
|
|
|
include proxy.conf;
|
|
|
|
}
|
|
|
|
|
|
|
|
location /api/version {
|
2024-05-18 18:36:13 +02:00
|
|
|
include auth_request.conf;
|
2023-10-21 15:15:24 +02:00
|
|
|
access_log off;
|
2024-04-11 13:41:07 +02:00
|
|
|
rewrite ^/api(/.*)$ $1 break;
|
2023-10-21 17:40:46 +02:00
|
|
|
proxy_pass http://frigate_api;
|
2023-10-21 15:15:24 +02:00
|
|
|
include proxy.conf;
|
|
|
|
}
|
2020-11-02 12:44:16 +01:00
|
|
|
}
|
2021-01-09 18:26:46 +01:00
|
|
|
|
|
|
|
location / {
|
2024-05-18 18:36:13 +02:00
|
|
|
# do not require auth for static assets
|
2022-04-25 15:00:01 +02:00
|
|
|
add_header Cache-Control "no-store";
|
|
|
|
expires off;
|
2021-01-29 06:04:52 +01:00
|
|
|
|
2022-04-25 15:00:01 +02:00
|
|
|
location /assets/ {
|
2021-01-29 06:04:52 +01:00
|
|
|
access_log off;
|
|
|
|
expires 1y;
|
|
|
|
add_header Cache-Control "public";
|
|
|
|
}
|
|
|
|
|
2022-05-19 14:31:02 +02:00
|
|
|
sub_filter 'href="/BASE_PATH/' 'href="$http_x_ingress_path/';
|
|
|
|
sub_filter 'url(/BASE_PATH/' 'url($http_x_ingress_path/';
|
|
|
|
sub_filter '"/BASE_PATH/dist/' '"$http_x_ingress_path/dist/';
|
|
|
|
sub_filter '"/BASE_PATH/js/' '"$http_x_ingress_path/js/';
|
|
|
|
sub_filter '"/BASE_PATH/assets/' '"$http_x_ingress_path/assets/';
|
2022-12-18 00:55:41 +01:00
|
|
|
sub_filter '"/BASE_PATH/monacoeditorwork/' '"$http_x_ingress_path/assets/';
|
2022-11-17 14:05:27 +01:00
|
|
|
sub_filter 'return"/BASE_PATH/"' 'return window.baseUrl';
|
2022-05-19 14:31:02 +02:00
|
|
|
sub_filter '<body>' '<body><script>window.baseUrl="$http_x_ingress_path/";</script>';
|
2021-01-20 02:58:17 +01:00
|
|
|
sub_filter_types text/css application/javascript;
|
|
|
|
sub_filter_once off;
|
2021-01-29 06:04:52 +01:00
|
|
|
|
2021-01-20 02:58:17 +01:00
|
|
|
root /opt/frigate/web;
|
2024-05-18 18:36:13 +02:00
|
|
|
try_files $uri $uri.html $uri/ /index.html;
|
2021-01-09 18:26:46 +01:00
|
|
|
}
|
2020-11-02 12:44:16 +01:00
|
|
|
}
|
2020-11-28 14:58:27 +01:00
|
|
|
}
|