2023-04-22 12:30:19 +01:00
|
|
|
{ config, pkgs, inputs, lib, ... }:
|
2023-04-22 22:37:02 +01:00
|
|
|
let
|
|
|
|
port = 8123;
|
|
|
|
path = "/data/nginx";
|
|
|
|
certPath = "${path}/cert.pem";
|
|
|
|
keyPath = "${path}/key.pem";
|
2022-11-09 17:50:48 +00:00
|
|
|
in {
|
2023-04-22 22:37:02 +01:00
|
|
|
imports = [ ../nginx.nix ./virtualisation.nix ];
|
2023-04-22 12:30:19 +01:00
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ port ];
|
2022-11-09 17:50:48 +00:00
|
|
|
|
2023-04-22 22:37:02 +01:00
|
|
|
services.nginx = {
|
|
|
|
virtualHosts = {
|
|
|
|
"bolty.raptor-carp.ts.net" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = false;
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://10.0.0.244:8123";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
sslCertificateKey = keyPath;
|
|
|
|
sslCertificate = certPath;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.nginx-tailscale-certs = {
|
|
|
|
script = ''
|
|
|
|
mkdir -p ${path}
|
|
|
|
cp -rv /var/lib/tailscale-certs/cert.pem ${certPath}
|
|
|
|
cp -rv /var/lib/tailscale-certs/key.pem ${keyPath}
|
|
|
|
chown -Rv nginx:nginx ${path}
|
|
|
|
'';
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
ReloadPropagatedFrom = "tailscale-cert.service";
|
|
|
|
};
|
|
|
|
before = [ "nginx.service" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [
|
|
|
|
"network.target"
|
|
|
|
"network-online.target"
|
|
|
|
"tailscaled.service"
|
|
|
|
"tailscale-cert.service"
|
|
|
|
];
|
|
|
|
wants = [ "tailscale-cert.service" ];
|
|
|
|
};
|
|
|
|
|
2022-08-28 08:28:54 +01:00
|
|
|
}
|