fail2banana.ru.nix 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. { config, pkgs, inputs, ... }:
  2. let
  3. dns = "regru";
  4. host = "fail2banana";
  5. domain = "${host}.ru";
  6. email = "padimych@gmail.com";
  7. in {
  8. roles.server = {
  9. inherit domain;
  10. adguardhome.enable = true;
  11. coturn = {
  12. enable = true;
  13. extraConfig = ''
  14. external-ip=37.194.158.176
  15. '';
  16. sharedSecretFile = config.age.secrets."coturn-${host}".path;
  17. };
  18. nextcloud = {
  19. enable = true;
  20. adminpassFile = config.age.secrets."nextcloud-${host}".path;
  21. home = "/data/nextcloud";
  22. };
  23. nginx.enable = true;
  24. synapse = {
  25. enable = true;
  26. dataDir = "/data/matrix-synapse";
  27. # element = true;
  28. registrationSharedSecretFile = config.age.secrets."synapse-${host}".path;
  29. };
  30. vaultwarden.enable = true;
  31. };
  32. age.secrets = with inputs.self.modules; {
  33. "${dns}-${host}".file = secrets."${dns}-${host}";
  34. "coturn-${host}" = {
  35. file = secrets."synapse-${host}";
  36. group = "turnserver";
  37. mode = "440";
  38. owner = "turnserver";
  39. };
  40. "nextcloud-${host}" = {
  41. file = secrets."nextcloud-${host}";
  42. group = "nextcloud";
  43. owner = "nextcloud";
  44. };
  45. "synapse-${host}" = {
  46. file = secrets."synapse-${host}";
  47. group = "matrix-synapse";
  48. owner = "matrix-synapse";
  49. };
  50. };
  51. security.acme.certs.${domain} = {
  52. credentialFiles.REGRU_PASSWORD_FILE = config.age.secrets."${dns}-${host}".path;
  53. environmentFile = pkgs.writeText "${dns}-env" ''
  54. REGRU_USERNAME=${email}
  55. REGRU_POLLING_INTERVAL=10
  56. REGRU_PROPAGATION_TIMEOUT=3600
  57. '';
  58. domain = "*." + domain;
  59. dnsPropagationCheck = true;
  60. dnsProvider = dns;
  61. dnsResolver = "ns1.reg.ru:53";
  62. inherit email;
  63. extraDomainNames = [ domain ];
  64. inherit (config.security.acme.defaults) group;
  65. # server = "https://acme-staging-v02.api.letsencrypt.org/directory";
  66. };
  67. services.nginx.virtualHosts = {
  68. ${domain} = {
  69. forceSSL = true;
  70. enableACME = true;
  71. acmeRoot = null;
  72. extraConfig = ''
  73. add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
  74. '';
  75. };
  76. "*.${domain}" = {
  77. default = true;
  78. forceSSL = true;
  79. useACMEHost = domain;
  80. globalRedirect = domain;
  81. };
  82. };
  83. }