diff options
-rw-r--r-- | hosts/ahmed/hellohtml.linus.onl/default.nix | 19 | ||||
-rw-r--r-- | modules/nixos/hellohtml/default.nix | 17 | ||||
-rw-r--r-- | secrets/cloudflare-ddns-token.env.age | bin | 1137 -> 1697 bytes |
3 files changed, 31 insertions, 5 deletions
diff --git a/hosts/ahmed/hellohtml.linus.onl/default.nix b/hosts/ahmed/hellohtml.linus.onl/default.nix index 584e030..4859ed3 100644 --- a/hosts/ahmed/hellohtml.linus.onl/default.nix +++ b/hosts/ahmed/hellohtml.linus.onl/default.nix @@ -1,21 +1,34 @@ # This module defines the HelloHTML web server. It extends the NGINX config # with a virtual server that proxies the local HelloHTML service. {...}: let + mainDomain = "hellohtml.linus.onl"; + altDomain = "hellohtml.ulovlighacker.download"; + useACME = true; in { config = { # Start service listening on socket /tmp/hellohtml.sock services.hellohtml = { enable = true; + inherit altDomain; }; - # Register domain name. - services.cloudflare-dyndns.domains = ["hellohtml.linus.onl"]; + # Register domain names. + services.cloudflare-dyndns.domains = [ + mainDomain + altDomain + ]; # Use NGINX as reverse proxy. - services.nginx.virtualHosts."hellohtml.linus.onl" = { + services.nginx.virtualHosts.${mainDomain}= { + # Set up secondary domain name to also point to this host. Only the + # client (browser) should treat these as separate. On the server, they + # are the same. + serverAliases = [altDomain]; + enableACME = useACME; forceSSL = useACME; + locations."/" = rec { proxyPass = "http://localhost:8538"; # Disable settings that might mess with the text/event-stream response of the /listen/:id endpoint. diff --git a/modules/nixos/hellohtml/default.nix b/modules/nixos/hellohtml/default.nix index cc15779..c70aa99 100644 --- a/modules/nixos/hellohtml/default.nix +++ b/modules/nixos/hellohtml/default.nix @@ -34,6 +34,18 @@ in { type = lib.types.port; default = 8538; }; + + altDomain = lib.mkOption { + description = '' + Hellohtml uses two separate domains: one serves the main editor and the + other serves the iframe embed. Since the main editor needs to embed the + iframe (served at the 2nd domain), the service needs to know the 2nd + domain. + + See the source code for more reasoning as to why this is necessary. + ''; + type = lib.types.str; + }; }; config = lib.mkIf cfg.enable { @@ -58,8 +70,8 @@ in { src = pkgs.fetchFromGitHub { owner = "linnnus"; repo = "hellohtml"; - rev = "97f00500712d8551d7bbf497ec442083c63384d0"; - hash = "sha256-6nbL2B26dc83F2gSLXadyfS8etuPhhlFy9ivG5l6Tog"; + rev = "51d2630578928173ea3ae57d97aeb5fa69b0dd7d"; + hash = "sha256-CAJoxSDQ8AriYRItsd+Hd1j2jI8CDcOF51a+EXV1P6s="; }; hellohtml-vendor = pkgs.stdenv.mkDerivation { @@ -83,6 +95,7 @@ in { export HELLOHTML_DB_PATH="${config.users.users.hellohtml.home}"/hello.db export HELLOHTML_PORT=${toString cfg.port} export HELLOHTML_BASE_DIR="${src}" + export HELLOHTML_ALT_DOMAIN="${cfg.altDomain}" ${pkgs.unstable.deno}/bin/deno run \ --allow-read=$HELLOHTML_BASE_DIR,$HELLOHTML_DB_PATH,. \ diff --git a/secrets/cloudflare-ddns-token.env.age b/secrets/cloudflare-ddns-token.env.age Binary files differindex 09b9b65..e52b3ef 100644 --- a/secrets/cloudflare-ddns-token.env.age +++ b/secrets/cloudflare-ddns-token.env.age |