]> Git — Sourcephile - sourcephile-nix.git/blob - machines/losurdo/nginx/sourcephile.fr/losurdo.nix
tor: update upstream PR
[sourcephile-nix.git] / machines / losurdo / nginx / sourcephile.fr / losurdo.nix
1 { domain, ... }:
2 { pkgs, lib, config, ... }:
3 let
4 inherit (config) networking;
5 inherit (config.security) gnupg;
6 inherit (config.services) nginx;
7 srv = "losurdo";
8 root = "/var/lib/nginx";
9 onion = "dfc66yn2fundui5yvq2ndx4nmcmbxpho4ji32tlc4cncrjvs2b5yu4id";
10 in
11 {
12 services.tor = {
13 relay.onionServices."nginx/${domain}/${srv}" = {
14 secretKey = gnupg.secrets."tor/onion/${onion}/hs_ed25519_secret_key".path;
15 map = [
16 80
17 #{ port = 443; target = { port = 8443; }; }
18 ];
19 authorizedClients = [
20 "descriptor:x25519:2EZQ3AOZXERDVSN6WO5LNSCOIIPL2AT2A7KOS4ZIYNVQDR5EFM2Q" # julm
21 ];
22 };
23 client.onionServices.${onion} = {
24 clientAuthorizations = [
25 gnupg.secrets."tor/auth/julm".path
26 ];
27 };
28 };
29 security.gnupg.secrets."tor/onion/${onion}/hs_ed25519_secret_key" = {};
30 security.gnupg.secrets."tor/auth/julm" = {};
31 services.nginx = {
32 virtualHosts."${srv}.${domain}" = {
33 serverAliases = [ domain "${onion}.onion" ];
34 #onlySSL = true;
35 #addSSL = true;
36 forceSSL = true;
37 useACMEHost = domain;
38 root = root;
39 extraConfig = ''
40 access_log /var/log/nginx/${domain}/${srv}/access.log json buffer=32k;
41 error_log /var/log/nginx/${domain}/${srv}/error.log warn;
42 '';
43 locations."/".extraConfig = ''
44 #autoindex on;
45 return 444;
46 '';
47 locations."/julm".extraConfig = ''
48 autoindex on;
49 fancyindex on;
50 fancyindex_exact_size off;
51 fancyindex_name_length 255;
52 open_file_cache off;
53 #open_file_cache_valid 1s;
54 '';
55 locations."/haskell".extraConfig = ''
56 autoindex on;
57 fancyindex on;
58 fancyindex_exact_size off;
59 fancyindex_name_length 255;
60 open_file_cache off;
61 #open_file_cache_valid 1s;
62 '';
63 locations."/sevy".extraConfig = ''
64 auth_basic "sevy's area";
65 auth_basic_user_file ${gnupg.secrets."nginx/sevy/htpasswd".path};
66 autoindex off;
67 '';
68 };
69 };
70 systemd.services.nginx = {
71 serviceConfig = {
72 LogsDirectory = lib.mkForce ["nginx/${domain}/${srv}"];
73 BindReadOnlyPaths = [
74 "/home/julm/work/sourcephile/web:${root}/julm"
75 "/home/julm/dl:${root}/dl"
76 "/home/julm/work/sourcephile/haskell:${root}/haskell"
77 ];
78 };
79 wants = [ gnupg.secrets."nginx/sevy/htpasswd".service ];
80 after = [ gnupg.secrets."nginx/sevy/htpasswd".service ];
81 };
82 security.gnupg.secrets."nginx/sevy/htpasswd" = {
83 # Generated with: echo "$user:$(openssl passwd -apr1)"
84 user = nginx.user;
85 group = nginx.group;
86 };
87 }