feat: deployed application to tor

This commit is contained in:
Leyla Becker 2026-02-11 18:57:53 -06:00
parent a330ae2b1c
commit 804cafad27
4 changed files with 92 additions and 13 deletions

View file

@ -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;
};
}

View file

@ -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 {