more plex

This commit is contained in:
Peder Bergebakken Sundt 2024-02-10 21:31:48 +01:00
parent 47b3a5112e
commit 216484a80c
2 changed files with 26 additions and 10 deletions

View File

@ -32,6 +32,11 @@ in
services.nginx.enable = true; services.nginx.enable = true;
networking.firewall.allowedTCPPorts = [ 80 443 ]; networking.firewall.allowedTCPPorts = [ 80 443 ];
services.nginx.recommendedGzipSettings = true;
services.nginx.recommendedOptimisation = true;
services.nginx.recommendedProxySettings = true;
services.nginx.recommendedTlsSettings = true;
/** / /** /
services.nginx.virtualHosts."" = { services.nginx.virtualHosts."" = {
default = true; default = true;

View File

@ -38,7 +38,7 @@
http2 = true; http2 = true;
locations."/" = { locations."/" = {
proxyPass = "http://127.0.0.1:32400"; # TODO: make configurable proxyPass = "http://127.0.0.1:32400"; # TODO: make configurable
#proxyWebsockets = true; proxyWebsockets = true;
}; };
# from https://nixos.wiki/wiki/Plex # from https://nixos.wiki/wiki/Plex
extraConfig = '' extraConfig = ''
@ -63,12 +63,12 @@
proxy_set_header Origin $server_addr; proxy_set_header Origin $server_addr;
# Plex has A LOT of javascript, xml and html. This helps a lot, but if it causes playback issues with devices turn it off. # Plex has A LOT of javascript, xml and html. This helps a lot, but if it causes playback issues with devices turn it off.
gzip on; #gzip on;
gzip_vary on; #gzip_vary on;
gzip_min_length 1000; #gzip_min_length 1000;
gzip_proxied any; #gzip_proxied any;
gzip_types text/plain text/css text/xml application/xml text/javascript application/x-javascript image/svg+xml; #gzip_types text/plain text/css text/xml application/xml text/javascript application/x-javascript image/svg+xml;
gzip_disable "MSIE [1-6]\."; #gzip_disable "MSIE [1-6]\.";
# Nginx default client_max_body_size is 1MB, which breaks Camera Upload feature from the phones. # Nginx default client_max_body_size is 1MB, which breaks Camera Upload feature from the phones.
# Increasing the limit fixes the issue. Anyhow, if 4K videos are expected to be uploaded, the size might need to be increased even more # Increasing the limit fixes the issue. Anyhow, if 4K videos are expected to be uploaded, the size might need to be increased even more
@ -89,9 +89,9 @@
proxy_set_header X-Plex-Model $http_x_plex_model; proxy_set_header X-Plex-Model $http_x_plex_model;
# Websockets # Websockets
proxy_http_version 1.1; #proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; #proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade"; #proxy_set_header Connection "upgrade";
# Buffering off send to the client as soon as the data is received from Plex. # Buffering off send to the client as soon as the data is received from Plex.
proxy_redirect off; proxy_redirect off;
@ -106,4 +106,15 @@
systemd.services.plex.serviceConfig.TimeoutStartSec = "5m"; systemd.services.plex.serviceConfig.TimeoutStartSec = "5m";
# restart plex weekly (needed to remain remotely available?!?!)
systemd.timers.restart-plex = {
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = "weekly";
timerConfig.Unit = "restart-plex.service";
};
systemd.services.restart-plex = {
serviceConfig.Type = "oneshot";
serviceConfig.ExecStart = "systemctl restart plex.socket";
};
} }