-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implement self signed cert and monitor/reload * move go2rtc upstream to separate file * add directory for ACME challenges * make certsync more resilient * add TLS docs * add jwt secret info to docs
- Loading branch information
1 parent
8418b65
commit bccffe6
Showing
25 changed files
with
633 additions
and
282 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
docker/main/rootfs/etc/s6-overlay/s6-rc.d/certsync-log/consumer-for
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
certsync |
Empty file.
1 change: 1 addition & 0 deletions
1
docker/main/rootfs/etc/s6-overlay/s6-rc.d/certsync-log/pipeline-name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
certsync-pipeline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
|
||
exec logutil-service /dev/shm/logs/certsync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
longrun |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
# Take down the S6 supervision tree when the service fails | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
# Logs should be sent to stdout so that s6 can collect them | ||
|
||
declare exit_code_container | ||
exit_code_container=$(cat /run/s6-linux-init-container-results/exitcode) | ||
readonly exit_code_container | ||
readonly exit_code_service="${1}" | ||
readonly exit_code_signal="${2}" | ||
readonly service="CERTSYNC" | ||
|
||
echo "[INFO] Service ${service} exited with code ${exit_code_service} (by signal ${exit_code_signal})" | ||
|
||
if [[ "${exit_code_service}" -eq 256 ]]; then | ||
if [[ "${exit_code_container}" -eq 0 ]]; then | ||
echo $((128 + exit_code_signal)) >/run/s6-linux-init-container-results/exitcode | ||
fi | ||
if [[ "${exit_code_signal}" -eq 15 ]]; then | ||
exec /run/s6/basedir/bin/halt | ||
fi | ||
elif [[ "${exit_code_service}" -ne 0 ]]; then | ||
if [[ "${exit_code_container}" -eq 0 ]]; then | ||
echo "${exit_code_service}" >/run/s6-linux-init-container-results/exitcode | ||
fi | ||
exec /run/s6/basedir/bin/halt | ||
fi |
1 change: 1 addition & 0 deletions
1
docker/main/rootfs/etc/s6-overlay/s6-rc.d/certsync/producer-for
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
certsync-log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/command/with-contenv bash | ||
# shellcheck shell=bash | ||
# Start the CERTSYNC service | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
# Logs should be sent to stdout so that s6 can collect them | ||
|
||
echo "[INFO] Starting certsync..." | ||
|
||
lefile="/etc/letsencrypt/live/frigate/fullchain.pem" | ||
|
||
|
||
while true | ||
do | ||
|
||
if [ ! -e $lefile ] | ||
then | ||
echo "[ERROR] TLS certificate does not exist: $lefile" | ||
fi | ||
|
||
leprint=`openssl x509 -in $lefile -fingerprint -noout || echo 'failed'` | ||
|
||
case "$leprint" in | ||
*Fingerprint*) | ||
;; | ||
*) | ||
echo "[ERROR] Missing fingerprint from $lefile" | ||
;; | ||
esac | ||
|
||
liveprint=`echo | openssl s_client -showcerts -connect 127.0.0.1:443 2>&1 | openssl x509 -fingerprint | grep -i fingerprint || echo 'failed'` | ||
|
||
case "$liveprint" in | ||
*Fingerprint*) | ||
;; | ||
*) | ||
echo "[ERROR] Missing fingerprint from current nginx TLS cert" | ||
;; | ||
esac | ||
|
||
if [[ "$leprint" != "failed" && "$liveprint" != "failed" && "$leprint" != "$liveprint" ]] | ||
then | ||
echo "[INFO] Reloading nginx to refresh TLS certificate" | ||
echo "$lefile: $leprint" | ||
/usr/local/nginx/sbin/nginx -s reload | ||
fi | ||
|
||
sleep 60 | ||
|
||
done | ||
|
||
exit 0 |
1 change: 1 addition & 0 deletions
1
docker/main/rootfs/etc/s6-overlay/s6-rc.d/certsync/timeout-kill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
30000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
longrun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# Wait for PID file to exist. | ||
while ! test -f /run/nginx.pid; do sleep 1; done |
1 change: 1 addition & 0 deletions
1
docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/notification-fd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
upstream go2rtc { | ||
server 127.0.0.1:1984; | ||
keepalive 1024; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
keepalive_timeout 70; | ||
listen [::]:443 ipv6only=off default_server ssl; | ||
|
||
ssl_certificate /etc/letsencrypt/live/frigate/fullchain.pem; | ||
ssl_certificate_key /etc/letsencrypt/live/frigate/privkey.pem; | ||
|
||
# generated 2024-06-01, Mozilla Guideline v5.7, nginx 1.25.3, OpenSSL 1.1.1w, modern configuration, no OCSP | ||
# https://ssl-config.mozilla.org/#server=nginx&version=1.25.3&config=modern&openssl=1.1.1w&ocsp=false&guideline=5.7 | ||
ssl_session_timeout 1d; | ||
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions | ||
ssl_session_tickets off; | ||
|
||
# modern configuration | ||
ssl_protocols TLSv1.3; | ||
ssl_prefer_server_ciphers off; | ||
|
||
# HSTS (ngx_http_headers_module is required) (63072000 seconds) | ||
add_header Strict-Transport-Security "max-age=63072000" always; | ||
|
||
# ACME challenge location | ||
location /.well-known/acme-challenge/ { | ||
default_type "text/plain"; | ||
root /etc/letsencrypt/www; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
id: tls | ||
title: TLS | ||
--- | ||
|
||
# TLS | ||
|
||
Frigate's integrated NGINX server supports TLS certificates. By default Frigate will generate a self signed certificate that will be used for port 443. Frigate is designed to make it easy to use whatever tool you prefer to manage certificates. | ||
|
||
Frigate is often running behind a reverse proxy that manages TLS certificates for multiple services. However, if you are running on a device that's separate from your proxy or if you expose Frigate directly to the internet, you may want to configure TLS. | ||
|
||
## Certificates | ||
|
||
TLS certificates can be mounted at `/etc/letsencrypt/live/frigate` using a bind mount or docker volume. | ||
|
||
```yaml | ||
frigate: | ||
... | ||
volumes: | ||
- /path/to/your/certificate_folder:/etc/letsencrypt/live/frigate | ||
... | ||
``` | ||
|
||
Within the folder, the private key is expected to be named `privkey.pem` and the certificate is expected to be named `fullchain.pem`. | ||
|
||
Frigate automatically compares the fingerprint of the certificate at `/etc/letsencrypt/live/frigate/fullchain.pem` against the fingerprint of the TLS cert in NGINX every minute. If these differ, the NGINX config is reloaded to pick up the updated certificate. | ||
|
||
## ACME Challenge | ||
|
||
Frigate also supports hosting the acme challenge files for the HTTP challenge method if needed. The challenge files should be mounted at `/etc/letsencrypt/www`. | ||
|
||
## Advanced customization | ||
|
||
If you would like to customize the TLS configuration, you can do so by using a bind mount to override `/usr/local/nginx/conf/tls.conf`. Check the source code for the default configuration and modify from there. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.