Skip to content

Commit

Permalink
nixos/acme: Make sure nginx is running before certs are requested
Browse files Browse the repository at this point in the history
This fixes NixOS#81842

We should probably also fix this for Apache, which recently also learned
to use ACME.
  • Loading branch information
arianvp committed Jun 15, 2020
1 parent 60247e8 commit 681cc10
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 4 additions & 0 deletions nixos/modules/services/web-servers/nginx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,10 @@ in
wantedBy = [ "multi-user.target" ];
wants = concatLists (map (vhostConfig: ["acme-${vhostConfig.serverName}.service" "acme-selfsigned-${vhostConfig.serverName}.service"]) acmeEnabledVhosts);
after = [ "network.target" ] ++ map (vhostConfig: "acme-selfsigned-${vhostConfig.serverName}.service") acmeEnabledVhosts;
# Nginx needs to be started in order to be able to request certificates
# (it's hosting the acme challenge after all)
# This fixes https://github.com/NixOS/nixpkgs/issues/81842
before = map (vhostConfig: "acme-${vhostConfig.serverName}.service") acmeEnabledVhosts;
stopIfChanged = false;
preStart = ''
${cfg.preStart}
Expand Down
6 changes: 0 additions & 6 deletions nixos/tests/acme.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ in import ./make-test-python.nix ({ lib, ... }: {
after = [ "acme-a.example.test.service" ];
wantedBy = [ "acme-a.example.test.service" ];
};
systemd.services."acme-a.example.test" = {
after = [ "nginx.service" ];
};

services.nginx.enable = true;

Expand All @@ -93,9 +90,6 @@ in import ./make-test-python.nix ({ lib, ... }: {
after = [ "acme-b.example.test.service" ];
wantedBy = [ "acme-b.example.test.service" ];
};
systemd.services."acme-b.example.test" = {
after = [ "nginx.service" ];
};
services.nginx.virtualHosts."b.example.test" = {
enableACME = true;
forceSSL = true;
Expand Down

0 comments on commit 681cc10

Please sign in to comment.