setup vps1 ingress

This commit is contained in:
nora 2024-07-26 22:21:48 +02:00
parent d925b4783e
commit 03c4ca2f95
5 changed files with 109 additions and 6 deletions

View file

@ -0,0 +1,29 @@
{
email nilstrieb@proton.me
}
# https://gist.github.com/ryanburnette/d13575c9ced201e73f8169d3a793c1a3
(cors) {
@cors_preflight{args.0} method OPTIONS
@cors{args.0} header Origin {args.0}
handle @cors_preflight{args.0} {
header {
Access-Control-Allow-Origin "{args.0}"
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
Access-Control-Allow-Credentials "false"
Access-Control-Allow-Headers "${args.1}"
Access-Control-Max-Age "86400"
defer
}
respond "" 204
}
handle @cors{args.0} {
header {
Access-Control-Allow-Origin "{args.0}"
Access-Control-Expose-Headers *
defer
}
}
}

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>nora' server</title>
</head>
<body>
<h1>congrats, you landed on my server (100% NixOS) directly!?</h1>
<p>sorry, but there isn't anything cool here. this is <b>my</b> infra, you are not allowed here.</p>
<p>if you do want to be allowed here, then uh.. still no.</p>
<p>:3</p>
</body>
</html>

View file

@ -1 +1,20 @@
{ ... }: { }
{ pkgs, ... }: {
networking.firewall.allowedTCPPorts = [
22
443
];
services.caddy = {
enable = true;
configFile = pkgs.writeText "Caddyfile"
(
builtins.readFile ./Caddyfile +
''
vps1.nilstrieb.dev {
root * ${./debugging-page}
file_server
}
''
);
};
}