improve module
This commit is contained in:
parent
f539b24544
commit
4cc95d96c7
|
@ -6,6 +6,8 @@
|
|||
pub-solar.paperless = {
|
||||
enable = true;
|
||||
hostStateDir = "/opt/documents/paperless";
|
||||
domain = "cox.lan";
|
||||
path = "/paperless";
|
||||
|
||||
ftp = {
|
||||
enable = true;
|
||||
|
|
|
@ -35,11 +35,16 @@ in {
|
|||
consumptionDirIsPublic = true;
|
||||
port = 8899;
|
||||
extraConfig = {
|
||||
PAPERLESS_FORCE_SCRIPT_NAME = "${cfg.path}";
|
||||
PAPERLESS_OCR_LANGUAGE = "deu+eng";
|
||||
PAPERLESS_ALLOWED_HOSTS = "${cfg.domain}";
|
||||
PAPERLESS_CSRF_TRUSTED_ORIGINS = "http://${cfg.domain}";
|
||||
PAPERLESS_CORS_ALLOWED_HOSTS = "http://${cfg.domain}";
|
||||
PAPERLESS_FILENAME_FORMAT = "{correspondent}/{created_year}/{asn}_{title}";
|
||||
PAPERLESS_FILENAME_FORMAT = "{created_year}/{correspondent}/{created_month}_{created_day}_{title}";
|
||||
PAPERLESS_TASK_WORKERS=2;
|
||||
PAPERLESS_CONSUMER_INOTIFY_DELAY=5;
|
||||
PAPERLESS_CONSUMER_RECURSIVE=1;
|
||||
PAPERLESS_CONSUMER_SUBDIRS_AS_TAGS=1;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,10 @@ with lib; let
|
|||
psCfg = config.pub-solar;
|
||||
cfg = config.pub-solar.paperless;
|
||||
in {
|
||||
imports = [./container.nix];
|
||||
imports = [
|
||||
./container.nix
|
||||
./nginx.nix
|
||||
];
|
||||
|
||||
options.pub-solar.paperless = {
|
||||
enable = mkEnableOption {default = false;};
|
||||
|
@ -18,6 +21,12 @@ in {
|
|||
default = "paperless.local";
|
||||
};
|
||||
|
||||
path = mkOption {
|
||||
type = types.str;
|
||||
description = "Sets the path to listen on. Use empty string to listen on root.";
|
||||
default = "";
|
||||
};
|
||||
|
||||
hostStateDir = mkOption {
|
||||
type = types.str;
|
||||
default = "/var/lib/paperless-container";
|
||||
|
@ -66,19 +75,5 @@ in {
|
|||
];
|
||||
};
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts."${cfg.domain}" = {
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:8899";
|
||||
proxyWebsockets = true;
|
||||
extraConfig = ''
|
||||
proxy_read_timeout 300s;
|
||||
proxy_set_header Host ''$host;
|
||||
proxy_set_header X-Forwarded-For ''$remote_addr;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
22
modules/paperless/nginx.nix
Normal file
22
modules/paperless/nginx.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{ config, ... }:
|
||||
|
||||
let
|
||||
cfg = config.pub-solar.paperless;
|
||||
nginxLocation = if cfg.path == "" then "/" else cfg.path;
|
||||
in
|
||||
{
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts."${cfg.domain}" = {
|
||||
locations."${nginxLocation}" = {
|
||||
proxyPass = "http://127.0.0.1:8899";
|
||||
proxyWebsockets = true;
|
||||
extraConfig = ''
|
||||
proxy_read_timeout 300s;
|
||||
proxy_set_header Host ${cfg.domain};
|
||||
proxy_set_header X-Forwarded-For ''$remote_addr;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue