summaryrefslogtreecommitdiff
path: root/hosts/poweredge-pro/filebrowser.nix
blob: b71940079a485d2c82416244e977f076495af8d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ pkgs, ... }: {
	containers.filebrowser = {
		autoStart = true;
		privateNetwork = true;
		hostBridge = "br-lan1";
		localMacAddress = "02:00:00:00:77:12";

		# Host path
		bindMounts = {
			"/var/lib/filebrowser/data/chexx" = {
				hostPath = "/Storage/chexx";
				isReadOnly = true;
			};
			"/var/lib/filebrowser/data/Scans" = {
				hostPath = "/Storage/Scans";
				isReadOnly = true;
			};
		};

		config = { lib, pkg, config, ... }: let
			publicPort = 9000;
		in {
			# Network
			networking.interfaces.eth0.useDHCP = true;
			networking.firewall.allowedTCPPorts = [ 80 publicPort ];  # Caddy (private + public)

			# Filebrowser
			services.filebrowser = {
				enable = true;
				#package = pkgs.filebrowser-quantum;  # Not supported yet
			};

			# Reverse proxy
			services.caddy = {
				enable = true;
				# Private
				virtualHosts.":80".extraConfig = ''
					reverse_proxy localhost:8080
				'';
				# Public (not sure why toString is needed but ok)
				virtualHosts.":${toString publicPort}".extraConfig = ''
					@shared {
						path /share/*
						path /static/*
						path /api/public/*
					}

					reverse_proxy @shared localhost:8080
				'';
			};

			system.stateVersion = "26.05";
		};
	};
}