]> Git — Sourcephile - sourcephile-nix.git/blob - machines/losurdo/nginx/sourcephile.fr/losurdo.nix
ssh: enable compression
[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."/sevy".extraConfig = ''
56 auth_basic "sevy's area";
57 auth_basic_user_file ${gnupg.secrets."nginx/sevy/htpasswd".path};
58 autoindex off;
59 '';
60 };
61 };
62 systemd.services.nginx = {
63 serviceConfig = {
64 LogsDirectory = lib.mkForce ["nginx/${domain}/${srv}"];
65 BindReadOnlyPaths = [
66 "/home/julm/work/sourcephile/web:${root}/julm"
67 "/home/julm/dl:${root}/dl"
68 "/home/julm/work/sourcephile/haskell:${root}/haskell"
69 ];
70 };
71 wants = [ gnupg.secrets."nginx/sevy/htpasswd".service ];
72 after = [ gnupg.secrets."nginx/sevy/htpasswd".service ];
73 };
74 security.gnupg.secrets."nginx/sevy/htpasswd" = {
75 # Generated with: echo "$user:$(openssl passwd -apr1)"
76 user = nginx.user;
77 group = nginx.group;
78 };
79 }