summaryrefslogtreecommitdiff
path: root/lib/nginx.nix
blob: e7c22c3850381c1d16d6dae42b1c29a0699d1aa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
lib: {
  # string -> int -> { }
  # create an nginx virtualHost submodule proxying local port
  # `port` to `endpoint`
  mkProxy = endpoint: port: {
    "${endpoint}" = {
      proxyPass = "http://localhost:${toString port}";
      proxyWebsockets = true;
    };
  };

  # string -> { } -> { }
  # transform the names of an attribute set of nginx virtualHosts
  # into a full subdomain
  toVHosts = domain: lib.mapAttrs' (name: lib.nameValuePair "${name}.${domain}");
}