Skip to content

Commit

Permalink
Enalbe attic and storage through frp
Browse files Browse the repository at this point in the history
  • Loading branch information
Albin Vass committed Jun 8, 2024
1 parent a5be4b2 commit de866ee
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
10 changes: 0 additions & 10 deletions nixos/hosts/nixpi/attic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@
};
};

services.cloudflared = {
tunnels = {
nixpi = {
ingress = {
"attic.albinvass.se" = "http://localhost:8080";
};
};
};
};

services.atticd = {
enable = true;
credentialsFile = config.sops.secrets."attic/credentialsFile".path;
Expand Down
9 changes: 8 additions & 1 deletion nixos/hosts/nixpi/frp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,19 @@
};
proxies = [
{
name = "http";
name = "attic.albinvass.se";
type = "tcp";
remotePort = 8082;
localIP = "127.0.0.1";
localPort = 8080;
}
{
name = "storage.albinvass.se";
type = "tcp";
remotePort = 8083;
localIP = "storage.";
localPort = 8080;
}
];
};
};
Expand Down
2 changes: 1 addition & 1 deletion nixos/hosts/reverse-proxy/frp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ in
settings = {
bindPort = frpPort;
proxyBindAddr = "127.0.0.1";
transport = {
transport = {
tls = {
force = true;
certFile = "{{ .Envs.CREDENTIALS_DIRECTORY }}/certFile";
Expand Down
29 changes: 16 additions & 13 deletions nixos/hosts/reverse-proxy/nginx.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ ... }:
{ nodes, lib, ... }:
{
networking.firewall.allowedTCPPorts = [
443
Expand All @@ -11,20 +11,23 @@
};
services.nginx = {
enable = true;
virtualHosts = {
"test.albinvass.se" = {
forceSSL = true;
enableACME = true;
locations = {
"/" = {
proxyPass = "http://127.0.0.1:8082";
};
};
};
"storage.albinvass.se" = {
virtualHosts = let
hostDefaults = {
forceSSL = true;
enableACME = true;
};
};
frpProxies = lib.attrsets.mergeAttrsList (map (node: with nodes.${node}.config.services.frp;
if builtins.hasAttr "proxies" settings
then builtins.listToAttrs(map (proxy: { name = "${proxy.name}"; value = hostDefaults // {
locations = {
"/" = {
proxyPass = "http://127.0.0.1:${builtins.toString proxy.remotePort}";
};
};
};}) settings.proxies)
else {}
) (builtins.attrNames nodes));

in frpProxies;
};
}

0 comments on commit de866ee

Please sign in to comment.