summary refs log tree commit diff stats
path: root/modules/pdf.nix
blob: 4f3805357bb564bda63d0ee623c1ed404358bf69 (plain) (blame)
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
{ pkgs, libs, config, ... }:
{

  services.stirling-pdf = {
    enable = true;
    environment = {
      SERVER_PORT = 5031;
    };
  };

  services.nginx.virtualHosts."pdf.krinitsin.com" = {
    forceSSL = true;
    useACMEHost = "krinitsin.com";
    locations."/" = {
      proxyPass = "http://localhost:5031";
      recommendedProxySettings = true;
      extraConfig = ''
        sub_filter '</body>' '<script> document.querySelectorAll(".go-pro-badge").forEach(badge => badge.remove()); </script></body>';
        sub_filter_once on;
      '';
    };
  };

  security.acme.certs."krinitsin.com".extraDomainNames = [ "pdf.krinitsin.com" ];

  services.monit.config = ''
    check process stirling-pdf with matching "stirling-pdf"
    start program = "${pkgs.systemd}/bin/systemctl start stirling-pdf"
    stop program = "${pkgs.systemd}/bin/systemctl stop stirling-pdf"
  '';
}