2021-12-12 22:31:33 +01:00
|
|
|
{ nglib, nixpkgs }:
|
|
|
|
nglib.makeSystem {
|
2021-05-12 12:22:48 +02:00
|
|
|
system = "x86_64-linux";
|
|
|
|
name = "nixng-ingress";
|
2021-12-12 22:31:33 +01:00
|
|
|
inherit nixpkgs;
|
2021-05-14 00:04:14 +02:00
|
|
|
config = ({ pkgs, config, nglib, ... }:
|
2021-05-12 12:22:48 +02:00
|
|
|
let
|
|
|
|
ids = config.ids;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = {
|
|
|
|
dumb-init = {
|
|
|
|
enable = true;
|
|
|
|
sigell = {
|
|
|
|
entries = [
|
|
|
|
{
|
|
|
|
signal = "HUP";
|
|
|
|
action = {
|
|
|
|
type = "exec";
|
|
|
|
environment = {
|
|
|
|
PATH = "${pkgs.bash}/bin:${pkgs.busybox}/bin";
|
|
|
|
};
|
|
|
|
command =
|
|
|
|
[ "bash"
|
|
|
|
"-c"
|
|
|
|
"kill -s HUP \"$(cat /nginx.pid)\""
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
signal = "TERM";
|
|
|
|
action = {
|
|
|
|
type = "signal";
|
|
|
|
rewrite = "TERM";
|
|
|
|
selector = {
|
|
|
|
type = "child";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
type.services = {};
|
|
|
|
};
|
|
|
|
init.services.nginx = {
|
|
|
|
shutdownOnExit = true;
|
|
|
|
};
|
2022-02-26 18:37:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
system.activation =
|
|
|
|
{ resolv-conf =
|
|
|
|
nglib.dag.dagEntryBefore [ "certbot" ]
|
|
|
|
''
|
|
|
|
export PATH=${pkgs.busybox}/bin
|
|
|
|
|
|
|
|
mkdir -p /etc
|
|
|
|
echo "nameserver 8.8.8.8" > /etc/resolv.conf
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-05-14 00:04:14 +02:00
|
|
|
services.certbot = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
acceptTerms = true;
|
|
|
|
|
|
|
|
domains = {
|
|
|
|
"redalder.org" = {
|
|
|
|
extraDomains = [
|
|
|
|
"hydra.redalder.org"
|
|
|
|
"gitea.redalder.org"
|
2022-09-19 01:11:59 +02:00
|
|
|
"matrix.redalder.org"
|
2021-05-14 00:04:14 +02:00
|
|
|
"nixng.org"
|
|
|
|
];
|
|
|
|
webroot = "/var/www/certbot";
|
|
|
|
email = "admin@redalder.org";
|
2022-02-26 18:37:07 +01:00
|
|
|
extraOptions = "--expand --keep-until-expiring --renew-with-new-domains -v";
|
|
|
|
};
|
2021-05-14 00:04:14 +02:00
|
|
|
};
|
|
|
|
};
|
2021-05-12 12:22:48 +02:00
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
envsubst = true;
|
|
|
|
configuration = [
|
|
|
|
{
|
|
|
|
daemon = "off";
|
|
|
|
worker_processes = 2;
|
|
|
|
user = "nginx";
|
|
|
|
|
|
|
|
events."" = {
|
|
|
|
use = "epoll";
|
|
|
|
worker_connections = 128;
|
|
|
|
};
|
|
|
|
|
|
|
|
error_log = [ "/dev/stderr" "warn" ];
|
|
|
|
|
|
|
|
pid = "/nginx.pid";
|
|
|
|
|
2021-12-12 22:31:33 +01:00
|
|
|
stream."" = {
|
|
|
|
include = [
|
|
|
|
[ "/local/streams.conf" ]
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2021-05-12 12:22:48 +02:00
|
|
|
http."" = {
|
|
|
|
server_tokens = "off";
|
|
|
|
include = [
|
|
|
|
[ "${pkgs.nginx}/conf/mime.types" ]
|
|
|
|
[ "/local/upstreams.conf" ]
|
|
|
|
];
|
|
|
|
charset = "utf-8";
|
2021-05-14 00:04:14 +02:00
|
|
|
access_log = [ "/dev/stdout" "combined" ];
|
|
|
|
|
|
|
|
server."" = {
|
2021-05-14 12:13:25 +02:00
|
|
|
listen = [ "80" "default_server" ];
|
|
|
|
server_name = [
|
|
|
|
"redalder.org"
|
|
|
|
"nixng.org"
|
|
|
|
];
|
2021-05-14 00:04:14 +02:00
|
|
|
|
|
|
|
location."/" = {
|
2021-05-14 12:13:25 +02:00
|
|
|
return = [ "301" "https://$$host$$request_uri" ];
|
2021-05-14 00:04:14 +02:00
|
|
|
};
|
|
|
|
};
|
2021-05-12 12:22:48 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|