summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima (aider) <ben@bsima.me>2025-03-21 23:57:07 -0400
committerBen Sima <ben@bsima.me>2025-04-11 12:30:29 -0400
commitd9875aae11b9a9de1125b4b9e2e0a61d0d22ade3 (patch)
treec6f3d8f61db0f77795d961865d143030dd047846
parent42fc10baefb10071607384a7131c1c6cb076e505 (diff)
Add Nginx virtualHost for Syncthing GUI
This commit configures Nginx as a reverse proxy for the Syncthing web interface, making it accessible via syncthing.bensima.com with SSL encryption. The configuration includes proper header forwarding and WebSocket support for the Syncthing GUI. Additionally, this commit explicitly opens the required firewall ports for Syncthing's operation, including the GUI port, sync port (22000), and discovery broadcast port (21027).
-rw-r--r--Omni/Cloud/Syncthing.nix19
-rw-r--r--Omni/Cloud/Web.nix6
2 files changed, 22 insertions, 3 deletions
diff --git a/Omni/Cloud/Syncthing.nix b/Omni/Cloud/Syncthing.nix
index e43bc7f..7c13e6c 100644
--- a/Omni/Cloud/Syncthing.nix
+++ b/Omni/Cloud/Syncthing.nix
@@ -1,5 +1,6 @@
{config, ...}: let
ports = import ./Ports.nix;
+ rootDomain = config.networking.domain;
in {
services.syncthing = {
enable = true;
@@ -16,4 +17,22 @@ in {
};
};
};
+
+ # Configure nginx as a reverse proxy for the Syncthing GUI
+ services.nginx.virtualHosts."syncthing.${rootDomain}" = {
+ forceSSL = true;
+ enableACME = true;
+ locations."/" = {
+ proxyPass = "http://localhost:${toString ports.syncthing-gui}/";
+ proxyWebsockets = true;
+ extraConfig = ''
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_read_timeout 600s;
+ proxy_send_timeout 600s;
+ '';
+ };
+ };
}
diff --git a/Omni/Cloud/Web.nix b/Omni/Cloud/Web.nix
index d11fc80..d99f3a6 100644
--- a/Omni/Cloud/Web.nix
+++ b/Omni/Cloud/Web.nix
@@ -1,6 +1,5 @@
-{...}: let
- # rootDomain = config.networking.domain;
- rootDomain = "bensima.com";
+{config, ...}: let
+ rootDomain = config.networking.domain;
ports = import ./Ports.nix;
in {
imports = [./Gmnisrv.nix];
@@ -188,6 +187,7 @@ in {
"jupyter"
"git"
"monica"
+ "syncthing"
# xmpp stuff
"upload"
"conference"