mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-25 23:07:07 +03:00
Nginx listen and cache header fixes (#25092)
* only add the ipv6 listener for wildcard listen addresses With IPv6 enabled, nginx also listened on [::] for both ports regardless of the configured listen address, so an internal port bound to 127.0.0.1 or [::1] was still reachable on every IPv6 address, and a [::]:port value rendered a duplicate listen that kept nginx from starting. The [::] listener is now added only for a bare port, *:port or 0.0.0.0:port, and a specific address binds only that address. * mark authorized media responses private in nginx
This commit is contained in:
@@ -183,7 +183,7 @@ http {
|
||||
}
|
||||
|
||||
expires 7d;
|
||||
add_header Cache-Control "public";
|
||||
add_header Cache-Control "private";
|
||||
autoindex on;
|
||||
root /media/frigate;
|
||||
|
||||
@@ -205,6 +205,7 @@ http {
|
||||
video/mp4 mp4;
|
||||
}
|
||||
|
||||
add_header Cache-Control "private";
|
||||
autoindex on;
|
||||
autoindex_format json;
|
||||
root /media/frigate;
|
||||
@@ -216,6 +217,7 @@ http {
|
||||
video/mp4 mp4;
|
||||
}
|
||||
|
||||
add_header Cache-Control "private";
|
||||
autoindex on;
|
||||
autoindex_format json;
|
||||
root /media/frigate;
|
||||
|
||||
@@ -8,7 +8,11 @@ from typing import Any
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
sys.path.insert(0, "/opt/frigate")
|
||||
from frigate.util.config import find_config_file, parse_listen_address
|
||||
from frigate.util.config import (
|
||||
find_config_file,
|
||||
ipv6_listen_address,
|
||||
parse_listen_address,
|
||||
)
|
||||
|
||||
sys.path.remove("/opt/frigate")
|
||||
|
||||
@@ -51,6 +55,9 @@ for key, default in (("internal", 5000), ("external", 8971)):
|
||||
|
||||
listen_config[key] = value
|
||||
listen_config[f"{key}_port"] = port
|
||||
listen_config[f"{key}_ipv6"] = (
|
||||
ipv6_listen_address(value, port) if ipv6_config["enabled"] else None
|
||||
)
|
||||
|
||||
if listen_config["internal_port"] == listen_config["external_port"]:
|
||||
print(
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# Internal (IPv4 always; IPv6 optional)
|
||||
# Internal; a wildcard address also listens on [::] when IPv6 is enabled
|
||||
listen {{ .listen.internal }};
|
||||
{{ if .ipv6.enabled }}listen [::]:{{ .listen.internal_port }};{{ end }}
|
||||
{{ if .listen.internal_ipv6 }}listen {{ .listen.internal_ipv6 }};{{ end }}
|
||||
|
||||
# intended for external traffic, protected by auth
|
||||
{{ if .tls.enabled }}
|
||||
# external HTTPS (IPv4 always; IPv6 optional)
|
||||
# external HTTPS
|
||||
listen {{ .listen.external }} ssl;
|
||||
{{ if .ipv6.enabled }}listen [::]:{{ .listen.external_port }} ssl;{{ end }}
|
||||
{{ if .listen.external_ipv6 }}listen {{ .listen.external_ipv6 }} ssl;{{ end }}
|
||||
|
||||
ssl_certificate {{ .tls.cert_path }}/fullchain.pem;
|
||||
ssl_certificate_key {{ .tls.cert_path }}/privkey.pem;
|
||||
@@ -30,7 +30,7 @@ listen {{ .listen.internal }};
|
||||
root /etc/letsencrypt/www;
|
||||
}
|
||||
{{ else }}
|
||||
# (No tls) default to HTTP (IPv4 always; IPv6 optional)
|
||||
# (No tls) default to HTTP
|
||||
listen {{ .listen.external }};
|
||||
{{ if .ipv6.enabled }}listen [::]:{{ .listen.external_port }};{{ end }}
|
||||
{{ if .listen.external_ipv6 }}listen {{ .listen.external_ipv6 }};{{ end }}
|
||||
{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user