summaryrefslogtreecommitdiff
path: root/hosts/cloud/proxy/auth.nix
blob: 6aa22e33e3280e4afff45525787ccc68d78d09ce (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
36
{ ... }:
{
  services.nginx.upstreams.authentik = {
    servers = {
      "10.89.88.11:9000" = { };
      "[fd31:185d:722f::11]:9000" = { };
    };
    extraConfig = ''
      keepalive 10;
    '';
  };

  services.nginx.virtualHosts."auth.oxapentane.com" = {
    forceSSL = true;
    enableACME = true;
    locations."/" = {
      proxyPass = "http://authentik";
      extraConfig = ''
        # general proxy settings
	    proxy_connect_timeout   60s;
	    proxy_send_timeout      60s;
	    proxy_read_timeout      60s;
	    proxy_http_version      1.1;
        proxy_set_header        Host $host;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Proto $scheme;
        proxy_set_header        X-Forwarded-Host $host;
        proxy_set_header        X-Forwarded-Server $host;
        # authentik specifik
        proxy_set_header        Upgrade $http_upgrade;
        proxy_set_header        Connection $connection_upgrade_keepalive;
      '';
    };
  };
}