feat(grocy): vouch reverse-proxy auth

This commit is contained in:
arcnmx 2024-03-20 12:54:08 -07:00
parent c27a8da537
commit bae4f32eff
7 changed files with 388 additions and 68 deletions

36
nixos/access/grocy.nix Normal file
View file

@ -0,0 +1,36 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf mkDefault;
inherit (config.services) grocy nginx;
name.shortServer = mkDefault "grocy";
in {
config.services.nginx.virtualHosts = {
grocy = {
inherit name;
locations."/" = mkIf (!grocy.enable) {
proxy.headers.enableRecommended = true;
extraConfig = ''
set $x_proxy_host ${nginx.virtualHosts.grocy.serverName};
'';
};
};
grocy'local = {
inherit name;
local.enable = mkDefault true;
locations."/" = mkIf (!grocy.enable) {
proxyPass = mkDefault (if grocy.enable
then "http://localhost:${nginx.defaultHTTPListenPort}"
else nginx.virtualHosts.grocy.locations."/".proxyPass
);
proxy.headers.enableRecommended = true;
extraConfig = ''
set $x_proxy_host ${nginx.virtualHosts.grocy.serverName};
proxy_redirect $x_scheme://${nginx.virtualHosts.grocy.serverName}/ $x_scheme://$x_host/;
'';
};
};
};
}