From ae5b577fe31c42ccc99401983e80e7763342e1eb Mon Sep 17 00:00:00 2001 From: Danilo Reyes Date: Sun, 24 Dec 2023 01:36:26 -0600 Subject: [PATCH] nginx optimization and collabora fucking works! --- server/nginx.nix | 57 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/server/nginx.nix b/server/nginx.nix index 671adbd..2a80fd5 100644 --- a/server/nginx.nix +++ b/server/nginx.nix @@ -6,8 +6,9 @@ let localhost = "127.0.0.1"; workstation = "192.168.1.64"; - jellyfinPort = "8096"; + jellyfinPort = 8096; nextcloudPort = 80; + collaboraPort = 9980; flamePort = 5005; secretFlamePort = 5007; lidarrPort = 8686; @@ -104,7 +105,9 @@ in { location = /web/ { # Proxy main Jellyfin traffic - proxy_pass http://${localhost}:${jellyfinPort}/web/index.html; + proxy_pass http://${localhost}:${ + toString (jellyfinPort) + }/web/index.html; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -115,11 +118,11 @@ in { ''; locations = { "/" = { - proxyPass = "http://${localhost}:${jellyfinPort}"; + proxyPass = "http://${localhost}:${toString (jellyfinPort)}"; proxyWebsockets = true; }; "/socket" = { - proxyPass = "http://${localhost}:${jellyfinPort}"; + proxyPass = "http://${localhost}:${toString (jellyfinPort)}"; extraConfig = '' proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; @@ -127,7 +130,7 @@ in { ''; }; "~ /Items/(.*)/Images" = { - proxyPass = "http://${localhost}:${jellyfinPort}"; + proxyPass = "http://${localhost}:${toString (jellyfinPort)}"; extraConfig = '' proxy_cache jellyfin; proxy_cache_revalidate on; @@ -135,7 +138,7 @@ in { ''; }; "~* ^/Videos/(.*)/(?!live)" = { - proxyPass = "http://${localhost}:${jellyfinPort}"; + proxyPass = "http://${localhost}:${toString (jellyfinPort)}"; extraConfig = '' # Set size of a slice (this amount will be always requested from the backend by nginx) # Higher value means more latency, lower more overhead @@ -170,12 +173,42 @@ in { enableACME = true; serverAliases = [ "cloud.rotehaare.art" ]; http2 = true; - # locations = { - # "/".proxyWebsockets = true; - # # uh, equals what? - # "~ ^/nextcloud/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|oc[ms]-provider/.+|.+/richdocumentscode/proxy).php(?:$|/)" = - # { }; - # }; + locations = { + "/".proxyWebsockets = true; + # uh, equals what? + "~ ^/nextcloud/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|oc[ms]-provider/.+|.+/richdocumentscode/proxy).php(?:$|/)" = + { }; + }; + }; + + "collabora.servidos.lat" = let + collaboraString = "http://${localhost}:${toString (collaboraPort)}"; + collaboraProxy = { + proxyPass = collaboraString; + extraConfig = '' + proxy_set_header Host $host; + ''; + }; + collaboraSocket = { + proxyPass = collaboraString; + extraConfig = '' + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host $host; + proxy_read_timeout 36000s; + ''; + }; + in base { + # static files + "^~ /loleaflet" = collaboraProxy; + # WOPI discovery URL + "^~ /hosting/discovery" = collaboraProxy; + # Capabilities + "^~ /hosting/capabilities" = collaboraProxy; + # download, presentation, image upload and websocket + "~ ^/lool" = collaboraSocket; + # Admin Console websocket + "^~ /lool/adminws" = collaboraSocket; }; }; };