Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/nginx: populate extraDomains with vhosts using useACMEHost #46379

Closed
wants to merge 1 commit into from

Conversation

vincentbernat
Copy link
Member

Motivation for this change

To reduce the number of issued certificates for LE, a solution is to
request one certificate for several domains. This can be done if all
domains are part of the same virual host definition (with
serverAliases) or by using useACMEHost instead of enableACME
attribute. In the later case, the user still had to add the
appropriate domains to the extraDomains attribute of the certificate.
We do that for them.

This has been tested with the following configuration:

security.acme.production = false;
services.nginx = {
 enable = true;
 recommendedTlsSettings   = true;

 virtualHosts."exo.89.145.160.62.nip.io" = {
   forceSSL = true;
   enableACME = true;
   serverAliases = [ "exo3.89.145.160.62.nip.io" ];
 };
 virtualHosts."exo2.89.145.160.62.nip.io" = {
   forceSSL = true;
   useACMEHost = "exo.89.145.160.62.nip.io";
   serverAliases = [ "exo4.89.145.160.62.nip.io" ];
 };
 virtualHosts."exo5.89.145.160.62.nip.io" = {
   forceSSL = true;
   enableACME = true;
 };
 virtualHosts."exo6.89.145.160.62.nip.io" = {
   forceSSL = true;
   enableACME = true;
   serverAliases = [ "exo7.89.145.160.62.nip.io" ];
 };
};

And I get certificates with the following subject alt names:

  • DNS:exo.89.145.160.62.nip.io, DNS:exo2.89.145.160.62.nip.io,
    DNS:exo3.89.145.160.62.nip.io, DNS:exo4.89.145.160.62.nip.io
  • DNS:exo5.89.145.160.62.nip.io
  • DNS:exo6.89.145.160.62.nip.io, DNS:exo7.89.145.160.62.nip.io
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

Sorry, something went wrong.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
To reduce the number of issued certificates for LE, a solution is to
request one certificate for several domains. This can be done if all
domains are part of the same virual host definition (with
serverAliases) or by using useACMEHost instead of enableACME
attribute. In the later case, the user still had to add the
appropriate domains to the extraDomains attribute of the certificate.
We do that for them.

This has been tested with the following configuration:

    security.acme.production = false;
    services.nginx = {
     enable = true;
     recommendedTlsSettings   = true;

     virtualHosts."exo.89.145.160.62.nip.io" = {
       forceSSL = true;
       enableACME = true;
       serverAliases = [ "exo3.89.145.160.62.nip.io" ];
     };
     virtualHosts."exo2.89.145.160.62.nip.io" = {
       forceSSL = true;
       useACMEHost = "exo.89.145.160.62.nip.io";
       serverAliases = [ "exo4.89.145.160.62.nip.io" ];
     };
     virtualHosts."exo5.89.145.160.62.nip.io" = {
       forceSSL = true;
       enableACME = true;
     };
     virtualHosts."exo6.89.145.160.62.nip.io" = {
       forceSSL = true;
       enableACME = true;
       serverAliases = [ "exo7.89.145.160.62.nip.io" ];
     };
    };

And I get certificates with the following subject alt names:

 - DNS:exo.89.145.160.62.nip.io, DNS:exo2.89.145.160.62.nip.io,
   DNS:exo3.89.145.160.62.nip.io, DNS:exo4.89.145.160.62.nip.io
 - DNS:exo5.89.145.160.62.nip.io
 - DNS:exo6.89.145.160.62.nip.io, DNS:exo7.89.145.160.62.nip.io
@GrahamcOfBorg GrahamcOfBorg added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Sep 8, 2018
@mmahut
Copy link
Member

mmahut commented Aug 7, 2019

Any updates on this pull request, please?

@dtzWill
Copy link
Member

dtzWill commented Jan 16, 2020

Ping? 😇

cc #40593 .

@aaronchall
Copy link
Contributor

Is this likely to be merged?

@mmahut
Copy link
Member

mmahut commented May 4, 2020

@GrahamcOfBorg test nginx acme

@ryantm ryantm added 2.status: merge conflict This PR has merge conflicts with the target branch and removed 2.status: merge conflict This PR has merge conflicts with the target branch labels Oct 3, 2020
@stale
Copy link

stale bot commented Jun 7, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 7, 2021
@wegank wegank marked this pull request as draft March 20, 2024 14:57
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants