简体   繁体   中英

How do I create a SSL certificate my domain including www using docker-nginx-certbot?

I'm serving a website using nginx via docker compose using this container.

If I follow the instructions, the container only generates a SSL certificate I name in the nginx.conf

ssl_certificate     /etc/letsencrypt/live/www.devenv.ai/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.devenv.ai/privkey.pem;

but not for devenv.ai . How do I get the container to automatically create a certificate for both www.devenv.ai and devenv.ai ?

You need to read the explanation how letsencrypt generates the certificate .

One approach is to get a wildcard certificate for devenv.ai , but this is question for system admins and beyond scope of stackowerflow, so you can research Super User, Server Fault or Ask Ubunty.

If you treat them as two separate domains, then to get the separate certificates (one for each domain), you need to have your agent listening on the HTTPS port (443) on both of the domains that you will try to get it certified.

This means, you need to:

  1. Set the DNS for both names to point to same IP address. Using alias for www.devenv.ai to point to devenv.ai would be the good approach.
  2. Create 2 server configurations in the nginx container, for each domain separately. With the container you had specified, easiest approach is to have 2 separate configuration files in the conf.d . This way you will have 2 domains running on nginx and you can decide either to keep them both, or to redirect one of them to the other one.

This can be extended to more than one domain just by adding configuration files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM