how to configure a letsencrypt certificate for two different domains on the same vhost?

413 Views Asked by At

Needs: I have a main site mymultisite.com and sub-site, sub1.mymultisite.com I configured them using sub-domain (not subfolder) Now I need to enable HTTPS for both of them, using LetsEncrypt.

Problems: I can successfully enable SSL for the main site (mymultisite.com).
But don’t know how to do with the subsite (sub1.mymultisite.com) yet.

What I tried:

  1. Option 1: From Linux (Debian), run: sudo certbot –-apache => It didn’t work as there’s no actual site named sub1.mymultisite.com

  2. Option 2: From Linux (Debian), run:

    certbot certonly --webroot -w /var/www/mymultisite.com/ -d sub1.mymultisite.com => It succeeded in generating the key. But when accessing the subsite from browser, it said:

    This server could not prove that it is sub1.mymultisite.com; its security certificate is from mymultisite.com. This may be caused by a misconfiguration or an attacker intercepting your connection.

1

There are 1 best solutions below

0
On

Resolved it by:

  1. From Linux, create corresponding .conf file under /etc/apache2/sites-available/subsite.mymultisite.com.conf for each subsite.
    Value of DocumentRoot is same as main site’s DocumentRoot (Eg: /var/www/sub1.mymainsite.com).
  2. Enable subsite using: a2ensite
  3. Run certbot as normal. It should work.