From 95733f9e054fd9e9b352121808e8e6198e9d0e4e Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 12 Jul 2021 19:07:39 +0200 Subject: [PATCH] services: paperless: setup reverse proxy --- hosts/poseidon/default.nix | 5 +++++ services/default.nix | 1 + services/paperless.nix | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 services/paperless.nix diff --git a/hosts/poseidon/default.nix b/hosts/poseidon/default.nix index 487f79f..059126c 100644 --- a/hosts/poseidon/default.nix +++ b/hosts/poseidon/default.nix @@ -120,6 +120,11 @@ in enable = true; }; + paperless = { + enable = true; + port = 8085; + }; + postgresql-backup = { enable = true; }; diff --git a/services/default.nix b/services/default.nix index 2ccf820..1761fc1 100644 --- a/services/default.nix +++ b/services/default.nix @@ -15,6 +15,7 @@ ./nextcloud.nix ./nginx.nix ./nuage.nix + ./paperless.nix ./pipewire.nix ./postgresql-backup.nix ./postgresql.nix diff --git a/services/paperless.nix b/services/paperless.nix new file mode 100644 index 0000000..a315251 --- /dev/null +++ b/services/paperless.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.my.services.paperless; + my = config.my; + domain = config.networking.domain; +in +{ + options.my.services.paperless = { + enable = lib.mkEnableOption "Paperless"; + + port = mkOption { + type = types.port; + default = 8080; + example = 8080; + description = "Internal port for Paperless service"; + }; + }; + + config = mkIf cfg.enable { + services.nginx.virtualHosts = { + "paperless.${domain}" = { + forceSSL = true; + enableACME = true; + + locations."/" = { + proxyPass = "http://127.0.0.1:${toString cfg.port}"; + proxyWebsockets = true; + }; + }; + }; + }; +}