diff --git a/config/arachnide/configuration.nix b/config/arachnide/configuration.nix index 916d33a..03bb096 100644 --- a/config/arachnide/configuration.nix +++ b/config/arachnide/configuration.nix @@ -4,10 +4,12 @@ imports = [ ./hardware-configuration.nix - /var/src/modules/nixin.nix + /var/src/modules/nixin-base.nix /var/src/modules/users.nix /var/src/modules/wireguard-client.nix /var/src/modules/reverse-proxy.nix + /var/src/modules/nginx.nix + /var/src/modules/nixin-web.nix ]; # Bootloader. diff --git a/modules/nginx.nix b/modules/nginx.nix new file mode 100644 index 0000000..7238981 --- /dev/null +++ b/modules/nginx.nix @@ -0,0 +1,16 @@ +{ + pkgs, + config, + lib, + ... +}: + +{ + services.nginx = { + enable = true; + + # Use recommended settings + recommendedGzipSettings = true; + recommendedOptimisation = true; + }; +} diff --git a/modules/nixin.nix b/modules/nixin-base.nix similarity index 100% rename from modules/nixin.nix rename to modules/nixin-base.nix diff --git a/modules/nixin-web.nix b/modules/nixin-web.nix new file mode 100644 index 0000000..e2913a1 --- /dev/null +++ b/modules/nixin-web.nix @@ -0,0 +1,53 @@ +{ + pkgs, + config, + lib, + ... +}: +let + nixin-web = pkgs.stdenv.mkDerivation { + pname = "nixin-web"; + version = "0.1-alpha"; + src = pkgs.fetchzip { + url = "https://git.distrilab.fr/NixiN/nixin-web/actions/runs/85/artifacts/nixin-website.zip"; + hash = "sha256-+cgWvbmjV9xckRCeRaj1dWqowBRbe/5497FcoZW+5ec="; + stripRoot = false; + }; + dontConfigure = true; + dontBuild = true; + installPhase = '' + mkdir -p $out + cp -a -T $src $out + ''; + }; +in +{ + services.nginx.virtualHosts."nixin.lab12.fr" = { + listen = [ + { + addr = "127.0.0.1"; + port = 8081; + ssl = false; + } + { + addr = "[::1]"; + port = 8081; + ssl = false; + } + ]; + forceSSL = false; + enableACME = false; + locations."/".root = ''${nixin-web}''; + locations."/".index = "index.html"; + }; + + services.traefik.dynamicConfigOptions.http.services."service-nixin-web" = { + loadBalancer.servers = [ + { url = "http://localhost:8081"; } + ]; + }; + services.traefik.dynamicConfigOptions.http.routers."router-nixin-web" = { + rule = "Host(`nixin.lab12.fr`)"; + service = "service-nixin-web"; + }; +} diff --git a/modules/reverse-proxy.nix b/modules/reverse-proxy.nix index be5805d..3d34dba 100644 --- a/modules/reverse-proxy.nix +++ b/modules/reverse-proxy.nix @@ -77,12 +77,7 @@ in }; - # Example proxy for a local service listening on port 8012 - services.traefik.dynamicConfigOptions.http.services."example.lab12.fr" = { - loadBalancer.servers = [ - { url = "http://127.0.0.1:8012"; } - ]; - }; + # You can find and example proxy for a non-docker service in the nixin-web.nix module # Example docker service with traefik proxy enabled through labels virtualisation.oci-containers.containers.whoami = {