mirror of
https://gitlab.com/simple-nixos-mailserver/nixos-mailserver.git
synced 2024-12-28 03:50:34 +05:00
initial acme support; needs testing
This commit is contained in:
parent
3b0818fb35
commit
2f7e3a9f0c
@ -138,7 +138,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
certificateScheme = mkOption {
|
certificateScheme = mkOption {
|
||||||
type = types.enum [ 1 2 ];
|
type = types.enum [ 1 2 3 ];
|
||||||
default = 2;
|
default = 2;
|
||||||
description = ''
|
description = ''
|
||||||
Certificate Files. There are three options for these.
|
Certificate Files. There are three options for these.
|
||||||
@ -149,8 +149,6 @@ in
|
|||||||
this implies that a stripped down webserver has to be started. This also
|
this implies that a stripped down webserver has to be started. This also
|
||||||
implies that the FQDN must be set as an `A` record to point to the IP of
|
implies that the FQDN must be set as an `A` record to point to the IP of
|
||||||
the server. TODO: Explain more details
|
the server. TODO: Explain more details
|
||||||
|
|
||||||
TODO: Only certificate scheme 1) and 2) work as of yet.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -256,5 +254,6 @@ in
|
|||||||
./mail-server/dovecot.nix
|
./mail-server/dovecot.nix
|
||||||
./mail-server/postfix.nix
|
./mail-server/postfix.nix
|
||||||
./mail-server/rmilter.nix
|
./mail-server/rmilter.nix
|
||||||
|
./mail-server/nginx.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,16 @@ in
|
|||||||
then cfg.certificateFile
|
then cfg.certificateFile
|
||||||
else if cfg.certificateScheme == 2
|
else if cfg.certificateScheme == 2
|
||||||
then "${cfg.certificateDirectory}/cert-${cfg.domain}.pem"
|
then "${cfg.certificateDirectory}/cert-${cfg.domain}.pem"
|
||||||
else "";
|
else if cfg.certificateScheme == 3
|
||||||
|
then "/var/lib/acme/acme-challenge/${cfg.hostPrefix}.${cfg.domain}/fullchain.pem"
|
||||||
|
else throw "Error: Certificate Scheme must be in { 1, 2, 3 }";
|
||||||
|
|
||||||
# key :: PATH
|
# key :: PATH
|
||||||
keyPath = if cfg.certificateScheme == 1
|
keyPath = if cfg.certificateScheme == 1
|
||||||
then cfg.keyFile
|
then cfg.keyFile
|
||||||
else if cfg.certificateScheme == 2
|
else if cfg.certificateScheme == 2
|
||||||
then "${cfg.certificateDirectory}/key-${cfg.domain}.pem"
|
then "${cfg.certificateDirectory}/key-${cfg.domain}.pem"
|
||||||
else "";
|
else if cfg.certificateScheme == 3
|
||||||
|
then "/var/lib/acme/acme-challenge/${cfg.hostPrefix}.${cfg.domain}/privkey.pem"
|
||||||
|
else throw "Error: Certificate Scheme must be in { 1, 2, 3 }";
|
||||||
}
|
}
|
||||||
|
43
mail-server/nginx.nix
Normal file
43
mail-server/nginx.nix
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# nixos-mailserver: a simple mail server
|
||||||
|
# Copyright (C) 2016-2017 Robin Raymond
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
|
||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
|
with (import ./common.nix { inherit config; });
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.mailserver;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = with cfg; lib.mkIf (certificateScheme == 3) {
|
||||||
|
|
||||||
|
services.nginx = {
|
||||||
|
enable = true;
|
||||||
|
virtualHosts = {
|
||||||
|
domain = {
|
||||||
|
serverName = "${hostPrefix}.${domain}";
|
||||||
|
forceSSL = true;
|
||||||
|
enableACME = true;
|
||||||
|
locations."/" = {
|
||||||
|
root = "/var/www";
|
||||||
|
};
|
||||||
|
acmeRoot = "/var/lib/acme/acme-challenge";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@ -49,9 +49,9 @@ let
|
|||||||
vaccounts_file = builtins.toFile "vaccounts" (lib.concatStringsSep "\n" (vaccounts_identity ++ valiases_postfix));
|
vaccounts_file = builtins.toFile "vaccounts" (lib.concatStringsSep "\n" (vaccounts_identity ++ valiases_postfix));
|
||||||
|
|
||||||
submissionHeaderCleanupRules = pkgs.writeText "submission_header_cleanup_rules" ''
|
submissionHeaderCleanupRules = pkgs.writeText "submission_header_cleanup_rules" ''
|
||||||
### Removes sensitive headers from mails handed in via the submission port.
|
# Removes sensitive headers from mails handed in via the submission port.
|
||||||
### See https://thomas-leister.de/mailserver-debian-stretch/
|
# See https://thomas-leister.de/mailserver-debian-stretch/
|
||||||
### Uses "pcre" style regex.
|
# Uses "pcre" style regex.
|
||||||
|
|
||||||
/^Received:/ IGNORE
|
/^Received:/ IGNORE
|
||||||
/^X-Originating-IP:/ IGNORE
|
/^X-Originating-IP:/ IGNORE
|
||||||
|
@ -63,6 +63,7 @@ in
|
|||||||
|
|
||||||
# Create certificates and maildir folder
|
# Create certificates and maildir folder
|
||||||
systemd.services.postfix = {
|
systemd.services.postfix = {
|
||||||
|
after = (if (certificateScheme == 3) then [ "nginx.service" ] else []);
|
||||||
preStart =
|
preStart =
|
||||||
''
|
''
|
||||||
# Create mail directory and set permissions. See
|
# Create mail directory and set permissions. See
|
||||||
|
Loading…
Reference in New Issue
Block a user