diff --git a/profiles/http/default.nix b/profiles/http/default.nix index 5b1ca99..9b34ce5 100644 --- a/profiles/http/default.nix +++ b/profiles/http/default.nix @@ -32,6 +32,11 @@ in services.nginx.enable = true; networking.firewall.allowedTCPPorts = [ 80 443 ]; + services.nginx.recommendedGzipSettings = true; + services.nginx.recommendedOptimisation = true; + services.nginx.recommendedProxySettings = true; + services.nginx.recommendedTlsSettings = true; + /** / services.nginx.virtualHosts."" = { default = true; diff --git a/profiles/http/services/plex.nix b/profiles/http/services/plex.nix index 426ee0c..346fd84 100644 --- a/profiles/http/services/plex.nix +++ b/profiles/http/services/plex.nix @@ -38,7 +38,7 @@ http2 = true; locations."/" = { proxyPass = "http://127.0.0.1:32400"; # TODO: make configurable - #proxyWebsockets = true; + proxyWebsockets = true; }; # from https://nixos.wiki/wiki/Plex extraConfig = '' @@ -63,12 +63,12 @@ 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. - gzip on; - gzip_vary on; - gzip_min_length 1000; - gzip_proxied any; - gzip_types text/plain text/css text/xml application/xml text/javascript application/x-javascript image/svg+xml; - gzip_disable "MSIE [1-6]\."; + #gzip on; + #gzip_vary on; + #gzip_min_length 1000; + #gzip_proxied any; + #gzip_types text/plain text/css text/xml application/xml text/javascript application/x-javascript image/svg+xml; + #gzip_disable "MSIE [1-6]\."; # 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 @@ -89,9 +89,9 @@ proxy_set_header X-Plex-Model $http_x_plex_model; # Websockets - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; + #proxy_http_version 1.1; + #proxy_set_header Upgrade $http_upgrade; + #proxy_set_header Connection "upgrade"; # Buffering off send to the client as soon as the data is received from Plex. proxy_redirect off; @@ -106,4 +106,15 @@ 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"; + }; + }