aboutsummaryrefslogtreecommitdiff
path: root/roles/web/proxy/default.nix
blob: 879ef12cd700af1cf0873e261a934405ab6254e0 (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
{ config, pkgs, lib, inputs, ... }:
with lib;

let cfg = config.roles.web.proxy; in {
  options.roles.web.proxy = {
    enable = mkEnableOption "nginx reverse proxy";
  };

  config = mkIf cfg.enable {
    networking.firewall.allowedTCPPorts = [ 80 ];

    services.nginx = {
      enable = true;
      virtualHosts = {
        "localhost".locations = {
          "/test" = {
            recommendedProxySettings = true;
            proxyPass = "http://192.168.0.2/";
          };
          "/stargazers" = {
            recommendedProxySettings = true;
            proxyPass = "http://192.168.0.3/";
          };
        };
      };
    };
  };
}