summaryrefslogtreecommitdiff
path: root/config/services/web/searx/default.nix
blob: 99fc91ae673c62c77a60d9915824a319af723c86 (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
{ config, lib, pkgs, ... }:

let
  cfg = {
    searx = config.services.searx;
    filtron = config.services.filtron;
  };
in {
  imports = [ ./searx ./filtron ./morty ];

  services.nginx.virtualHosts.searx =
    lib.mkIf (cfg.searx.enable && cfg.filtron.enable) {
      serverName = "searx.${config.networking.domain}";
      locations = {
        "/" = {
          proxyPass = "http://${cfg.filtron.listen.address}:${
              toString cfg.filtron.listen.port
            }";
          extraConfig = ''
            proxy_set_header Host            $host;
            proxy_set_header Connection      $http_connection;
            proxy_set_header X-Real-IP       $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Scheme        $scheme;
            # proxy_set_header X-Script-Name   /;
          '';
        };
        "/static/".alias = "${cfg.searx.package}/share/static/";
      };
      forceSSL = true;
      enableACME = true;
    };

  personal.monitoring.services = [ "uwsgi" ];
}