diff options
author | Ben Sima (aider) <ben@bsima.me> | 2025-03-21 23:57:07 -0400 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2025-04-11 12:30:29 -0400 |
commit | d9875aae11b9a9de1125b4b9e2e0a61d0d22ade3 (patch) | |
tree | c6f3d8f61db0f77795d961865d143030dd047846 /Omni/Cloud/Syncthing.nix | |
parent | 42fc10baefb10071607384a7131c1c6cb076e505 (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).
Diffstat (limited to 'Omni/Cloud/Syncthing.nix')
-rw-r--r-- | Omni/Cloud/Syncthing.nix | 19 |
1 files changed, 19 insertions, 0 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; + ''; + }; + }; } |