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