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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
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.

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
@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

Is this likely to be merged?

@mmahut
Copy link
Member

mmahut commented May 4, 2020

@GrahamcOfBorg test nginx acme

@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants