Skip to content

Commit

Permalink
Move services to IPv6/TLS internally
Browse files Browse the repository at this point in the history
  • Loading branch information
peterablehmann committed Sep 19, 2024
1 parent 1987d82 commit 841a9a9
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
3 changes: 2 additions & 1 deletion modules/common/exporters.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ in
forceSSL = true;
kTLS = true;
locations."/" = {
proxyPass = "https://localhost:${builtins.toString config.services.prometheus.exporters.node.port }";
proxyPass = "https://${config.services.prometheus.exporters.node.listenAddress}:${builtins.toString config.services.prometheus.exporters.node.port }";
};
};

services.prometheus.exporters.node = {
enable = true;
listenAddress = "[::1]";
port = 3043;
enabledCollectors = [
"systemd"
Expand Down
3 changes: 2 additions & 1 deletion modules/monitoring/blackbox.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ in
kTLS = true;
forceSSL = true;
locations."/" = {
proxyPass = "https://localhost:${builtins.toString config.services.prometheus.exporters.blackbox.port }";
proxyPass = "https://${config.services.prometheus.exporters.blackbox.listenAddress}:${builtins.toString config.services.prometheus.exporters.blackbox.port }";
};
};

services.prometheus.exporters.blackbox = {
enable = true;
listenAddress = "[::1]";
port = 3044;
extraFlags = [
"--web.config.file=${webConfig}"
Expand Down
6 changes: 3 additions & 3 deletions modules/monitoring/grafana.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ in
kTLS = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://${config.services.grafana.settings.server.http_addr}:${builtins.toString config.services.grafana.settings.server.http_port }";
proxyPass = "http://[${config.services.grafana.settings.server.http_addr}]:${builtins.toString config.services.grafana.settings.server.http_port }";
proxyWebsockets = true;
};
};
Expand All @@ -34,7 +34,7 @@ in
enable = true;
settings = {
server = {
http_addr = "127.0.0.1";
http_addr = "::1";
http_port = 3312;
root_url = "https://${domain}";
inherit domain;
Expand Down Expand Up @@ -62,7 +62,7 @@ in
datasources.settings.datasources = [
{
name = "prometheus";
url = "http://localhost:9001";
url = "http://${config.services.prometheus.listenAddress}:${builtins.toString config.services.prometheus.port}";
type = "prometheus";
editable = false;
}
Expand Down
1 change: 1 addition & 0 deletions modules/monitoring/prometheus.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
services = {
prometheus = {
enable = true;
listenAddress = "[::1]";
port = 9001;
checkConfig = "syntax-only";
retentionTime = "90d";
Expand Down
2 changes: 2 additions & 0 deletions modules/paperless.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ in
services.paperless = {
enable = true;
passwordFile = config.sops.secrets."paperless/password".path;
address = "[::1]";
port = 28981;
settings = {
PAPERLESS_ADMIN_USER = "peter";
PAPERLESS_PRE_CONSUME_SCRIPT = pre_consume_script.outPath;
Expand Down
19 changes: 16 additions & 3 deletions modules/restic-server/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}:
let
domain = "restic.${config.networking.hostName}.xnee.net";
tls-dir = config.security.acme.certs.${domain}.directory;
in
{
security.acme.certs."${domain}" = { };
Expand All @@ -13,17 +14,29 @@ in
kTLS = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://${config.services.restic.server.listenAddress}";
proxyPass = "https://${config.services.restic.server.listenAddress}";
extraConfig = "client_max_body_size 10G;";
};
};

systemd.services.restic-rest-server = {
serviceConfig = {
SupplementaryGroups = [ config.security.acme.certs.${domain}.group ];
BindReadOnlyPaths = [ tls-dir ];
};
};

services.restic.server = {
enable = true;
dataDir = "/var/lib/restic";
appendOnly = true;
listenAddress = "127.0.0.1:8000";
listenAddress = "[::1]:8000";
privateRepos = true;
extraFlags = [ "--htpasswd-file=${./.htpasswd}" ];
extraFlags = [
"--htpasswd-file=${./.htpasswd}"
"--tls"
"--tls-cert=${tls-dir}/fullchain.pem"
"--tls-key=${tls-dir}/key.pem"
];
};
}
2 changes: 1 addition & 1 deletion modules/syncthing.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ in
services.syncthing = {
enable = true;
dataDir = "/var/lib/syncthing";
guiAddress = "127.0.0.1:8384";
guiAddress = "[::1]:8384";
settings = {
gui.insecureSkipHostcheck = true;
devices = {
Expand Down

0 comments on commit 841a9a9

Please sign in to comment.