modified setup.nix so that the proxy functions take cfg
This commit is contained in:
@@ -41,30 +41,25 @@ let
|
||||
default = "${config.my.servers.${name}.hostName}" == config.my.mainServer;
|
||||
};
|
||||
};
|
||||
proxy = locations: {
|
||||
proxy = cfg: locations: {
|
||||
inherit locations;
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
http2 = true;
|
||||
# listenAddresses = [ cfg.ip ];
|
||||
};
|
||||
proxyReverse =
|
||||
host: port:
|
||||
let
|
||||
useLocalhost = host == config.networking.hostName;
|
||||
proxyTarget = if useLocalhost then config.my.localhost else config.my.ips."${host}";
|
||||
in
|
||||
proxy { "/".proxyPass = "http://${proxyTarget}:${toString port}/"; };
|
||||
proxyReverse = cfg: proxy cfg { "/".proxyPass = "http://${cfg.ip}:${toString cfg.port}/"; };
|
||||
proxyReverseFix =
|
||||
host: port:
|
||||
cfg:
|
||||
let
|
||||
useLocalhost = host == config.networking.hostName;
|
||||
useLocalhost = cfg.hostName == config.networking.hostName;
|
||||
localHeaders = ''
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
'';
|
||||
in
|
||||
proxyReverse host port
|
||||
proxyReverse cfg
|
||||
// {
|
||||
extraConfig = ''
|
||||
${if useLocalhost then localHeaders else ""}
|
||||
|
||||
Reference in New Issue
Block a user