From 804cafad279dccc8b6fb2bb95304612525ee22e2 Mon Sep 17 00:00:00 2001 From: Leyla Becker Date: Wed, 11 Feb 2026 18:57:53 -0600 Subject: [PATCH] feat: deployed application to tor --- _includes/base.njk | 6 +++++ assets/onion-icon.svg | 6 +++++ nix/configuration.nix | 34 ++++++++++++++++++++++++- nix/module.nix | 59 ++++++++++++++++++++++++++++++++++--------- 4 files changed, 92 insertions(+), 13 deletions(-) create mode 100644 assets/onion-icon.svg diff --git a/_includes/base.njk b/_includes/base.njk index bdd4892..88af7a7 100644 --- a/_includes/base.njk +++ b/_includes/base.njk @@ -83,6 +83,12 @@
source + + + Tor Onion Logo + + onion mirror + © {{ page.date.getFullYear() }} Volpe
diff --git a/assets/onion-icon.svg b/assets/onion-icon.svg new file mode 100644 index 0000000..5b8ca60 --- /dev/null +++ b/assets/onion-icon.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/nix/configuration.nix b/nix/configuration.nix index 8ec82a3..e499384 100644 --- a/nix/configuration.nix +++ b/nix/configuration.nix @@ -35,8 +35,40 @@ services.volpe = { enable = true; domain = "blog.jan-leila.com"; - extraDomains = ["volpe.jan-leila.com"]; + extraDomains = [ + "volpe.jan-leila.com" + "2ggpzgonqsll5gi56u47aywu4qyl37eiu5jjrq7ma43z77ekkwuqxmid.onion" + ]; enableACME = true; acmeEmail = "leyla@jan-leila.com"; }; + + services.tor = { + enable = true; + enableGeoIP = false; + relay.onionServices = { + volpe = { + version = 3; + map = [ + { + port = 80; + target = { + addr = "[::1]"; + port = 80; + }; + } + ]; + }; + }; + settings = { + ClientUseIPv4 = true; + ClientUseIPv6 = true; + ClientPreferIPv6ORPort = true; + }; + }; + + services.snowflake-proxy = { + enable = true; + capacity = 100; + }; } diff --git a/nix/module.nix b/nix/module.nix index 796dc2d..0e780e2 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -6,21 +6,27 @@ }: let cfg = config.services.volpe; - mkPkg = domain: + isOnion = domain: lib.hasSuffix ".onion" domain; + + mkPkg = domain: let + protocol = + if isOnion domain + then "http" + else "https"; + in pkgs.callPackage ./package.nix { - siteUrl = "https://${domain}"; + siteUrl = "${protocol}://${domain}"; }; allDomains = [cfg.domain] ++ cfg.extraDomains; + regularDomains = lib.filter (d: !(isOnion d)) allDomains; + onionDomains = lib.filter isOnion cfg.extraDomains; - mkVirtualHost = domain: { + mkHost = domain: { root = "${mkPkg domain}"; - forceSSL = cfg.enableACME; - enableACME = cfg.enableACME; locations."/" = { tryFiles = "$uri $uri/ /index.html"; }; - # Cache static assets (CSS, JS, images) for 1 year with immutable locations."~* \\.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$" = { extraConfig = '' expires 1y; @@ -29,6 +35,28 @@ ''; }; }; + + mkVirtualHost = domain: + { + forceSSL = cfg.enableACME; + enableACME = cfg.enableACME; + } + // (mkHost domain); + + mkOnionVirtualHost = domain: + { + listen = [ + { + addr = "[::1]"; + port = 80; + } + { + addr = "127.0.0.1"; + port = 80; + } + ]; + } + // (mkHost domain); in { options.services.volpe = { enable = lib.mkEnableOption "volpe blog"; @@ -64,13 +92,20 @@ in { recommendedOptimisation = true; recommendedGzipSettings = true; recommendedProxySettings = true; + serverNamesHashBucketSize = 128; - # Create a virtualHost for each domain - virtualHosts = lib.listToAttrs (map (domain: { - name = domain; - value = mkVirtualHost domain; - }) - allDomains); + virtualHosts = lib.listToAttrs ( + (map (domain: { + name = domain; + value = mkVirtualHost domain; + }) + regularDomains) + ++ (map (domain: { + name = domain; + value = mkOnionVirtualHost domain; + }) + onionDomains) + ); }; security.acme = lib.mkIf cfg.enableACME {