feat(sni-proxy): init
All checks were successful
lint / check (push) Successful in 24s
build configuration / build_krz01 (push) Successful in 2m6s

This commit is contained in:
sinavir 2024-12-22 02:46:44 +01:00
parent 138ea89bbc
commit 930c1bd90a
7 changed files with 127 additions and 0 deletions

View file

@ -8,6 +8,7 @@ lib.extra.mkConfig {
enabledServices = [ enabledServices = [
# List of services to enable # List of services to enable
"unbound" "unbound"
"nginx"
]; ];
extraConfig = { }; extraConfig = { };

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -0,0 +1,93 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>Ouverture K-Fêt</title>
<style>
#main {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
text-align: center;
font-weight: bold;
font-size: 15vw;
display: flex;
justify-content: center;
align-content: center;
flex-direction: column;
}
* {
margin: 0;
padding: 0;
}
.red {
background-color: red;
color: white;
}
.orange {
background-color: orange;
color: black;
}
.green {
background-color: green;
color: white;
}
#main > p {
overflow: hidden;
display: none;
}
.orange > #orange {
display: block;
}
.green > #green {
display: block;
}
.red > #red {
display: block;
}
</style>
<link rel="manifest" href="manifest.webmanifest" />
</head>
<body>
<div id="main" class="orange">
<p id="orange">Non défini</p>
<p id="red">Fermé</p>
<p id="green">Ouvert</p>
</div>
<script>
// Créer une connexion WebSocket
const socket = new WebSocket('wss://kfet.sinavir.fr/ws/');
const div = document.getElementById("main");
// Écouter les messages
socket.addEventListener('message', function (event) {
console.log('Voici un message du serveur', event.data);
switch (JSON.parse(event.data).status) {
case "opened":
div.className = "green";
document.title = "🟢 Ouvert | K-Fêt";
break;
case "closed":
div.className = "red";
document.title = "🔴 Fermé | K-Fêt";
break;
default:
div.className = "orange";
document.title = "🟠 Indéfini | K-Fêt";
}
});
</script>
</body>
</html>

View file

@ -0,0 +1,8 @@
{
dgn-web.enable = true;
services.nginx.virtualHosts."kfet.lab.dgnum.eu" = {
enableACME = true;
forceSSL = true;
root = ./kfet;
};
}

View file

@ -9,6 +9,7 @@ lib.extra.mkConfig {
# List of services to enable # List of services to enable
"networking" "networking"
"wireguard" "wireguard"
"nginx-sni"
]; ];
extraConfig = { }; extraConfig = { };

View file

@ -0,0 +1,21 @@
{ meta, ... }:
let
# Beware, jool will not translate. Prefer ipv6 proxy target
machines = builtins.mapAttrs (
host: { site, ... }: "v6.${host}.${site}.infra.lab.dgnum.eu:443"
) meta.nodes;
in
{
dgn-web.enable = true;
services.nginx = {
sni-proxy = {
preStreamConfig = ''
resolver 127.0.0.53;
'';
enable = true;
redirects = {
"kfet.lab.dgnum.eu" = machines.labcore01;
};
};
};
}

View file

@ -9,6 +9,9 @@
++ [ ++ [
"${sources."microvm.nix"}/nixos-modules/host" "${sources."microvm.nix"}/nixos-modules/host"
(import sources.proxmox-nixos).nixosModules.declarative-vms (import sources.proxmox-nixos).nixosModules.declarative-vms
]
++ (import sources.nix-modules { inherit lib; }).importModules [
"services/nginx-sni"
]; ];
dgn-notify.enable = false; dgn-notify.enable = false;