2

I need to be able to manage thousands of domains in nginx, and each domain will have a lets-encrypt certification that I will manage.

I was reading how apache has a macro feature that lets you do something like where you don't have to repeat the same virtual host section for each domain.

If you have thousands of domains to manage this can come in handy.

Does nginx have something similar that can help in this regard?

<Macro VHost $domain>
<VirtualHost *:443>
    ProxyProtocol On
    ServerName $domain

    SSLEngine on
    SSLCertificateFile      $domain.crt
    SSLCertificateKeyFile   $domain.key
    SSLCertificateChainFile lets-encrypt-cross-signed.pem
</VirtualHost>
cool breeze
  • 101
  • 8

1 Answers1

3

With Nginx, you would do this beforehand, using external tools like nginx-confgen to create a static config. The reason for not using variables in configuration is explained in Nginx FAQ:

Variables should not be used as template macros. Variables are evaluated in the run-time during the processing of each request, so they are rather costly compared to plain static configuration. Using variables to store static strings is also a bad idea. Instead, a macro expansion and "include" directives should be used to generate configs more easily and it can be done with the external tools, e.g. sed + make or any other common template mechanism.

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129