How to enable SSL certificates for 2 domains

Keywords: PrestaShop - Google Cloud Platform - How to - Secure Connections (SSL/HTTPS)
Description:
i was trying to use the Lets Encrypt tool to enable ssl certificates for a new domain in prestashop and it only works for 1 domain.

I’ve reading and i know i have to create a virtual host and configure another file to redirect the port.

Can you help me with the route of the file i have to edit and the file structure.

Hi @aaldanap92,

You can generate one single SSL certificate file that contains the information of all your domains. If you used the Bitnami HTTPS configuration tool, you can run it again and set all your domains when generating the certificate information. If it asks you to revoke the current certificate first, you will need to follow this guide and then run the tool again

https://docs.bitnami.com/google/how-to/understand-bncert/#manually-revoking-an-existing-certificate

If you want to have different domains in pointing to the same instance and serving different information, you will need to create a virtual host to serve that second site. You can learn more about that here

https://docs.bitnami.com/google/apps/prestashop/administration/redirect-custom-domains/

Happy to help!


Was my answer helpful? Click on :heart:

I did This is what i did following the guideline in:
https://docs.bitnami.com/google/apps/prestashop/administration/redirect-custom-domains/

In the file /opt/bitnami/apache2/conf/vhosts/prestashop-vhost.conf i add:

<VirtualHost *:80>
    ServerName yaveo.co
    ServerAlias www.yaveo.co
 
# BEGIN: Configuration for letsencrypt
  Include "/opt/bitnami/apps/letsencrypt/conf/httpd-prefix.conf"
  # END: Configuration for letsencrypt
  # BEGIN: Support domain renewal when using mod_proxy without Location
  <IfModule mod_proxy.c>
    ProxyPass /.well-known !
  </IfModule>
  # END: Support domain renewal when using mod_proxy without Location
  # BEGIN: Support domain renewal when using mod_proxy within Location
  <Location /.well-known>
    <IfModule mod_proxy.c>
      ProxyPass !
    </IfModule>
  </Location>
  # END: Support domain renewal when using mod_proxy within Location
  # BEGIN: Enable HTTP to HTTPS redirection
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} !^localhost
  RewriteCond %{HTTP_HOST} !^[0-9]+.[0-9]+.[0-9]+.[0-9]+(:[0-9]+)?$
  RewriteCond %{REQUEST_URI} !^/\.well-known
  RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
  # END: Enable HTTP to HTTPS redirection
</VirtualHost>

and in the file /opt/bitnami/apache2/conf/vhosts/prestashop-https-vhost.conf i add:

<VirtualHost *:443>
    ServerName yaveo.co
    ServerAlias yaveo.co
 SSLCertificateFile "/opt/bitnami/apache2/conf/yaveo.co.crt"
  SSLCertificateKeyFile "/opt/bitnami/apache2/conf/yaveo.co.key"
  # BEGIN: Configuration for letsencrypt
  Include "/opt/bitnami/apps/letsencrypt/conf/httpd-prefix.conf"
  # END: Configuration for letsencrypt
  # BEGIN: Support domain renewal when using mod_proxy without Location
  <IfModule mod_proxy.c>
    ProxyPass /.well-known !
  </IfModule>
  # END: Support domain renewal when using mod_proxy without Location
  # BEGIN: Support domain renewal when using mod_proxy within Location
  <Location /.well-known>
    <IfModule mod_proxy.c>
      ProxyPass !
    </IfModule>
  </Location>
  # END: Support domain renewal when using mod_proxy within Location
  # BEGIN: Enable HTTP to HTTPS redirection
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} !^localhost
  RewriteCond %{HTTP_HOST} !^[0-9]+.[0-9]+.[0-9]+.[0-9]+(:[0-9]+)?$
  RewriteCond %{REQUEST_URI} !^/\.well-known
  RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
  # END: Enable HTTP to HTTPS redirection
</VirtualHost>

And it did not work. what ir missing what is wrong. Help please

Hi @aaldanap92,

I just accessed your site (yaveo.co) and checked that the SSL certificate is valid for the opticaconfortcenter.com domain. I understand that’s your main domain, right? Did you reboot the Apache’s service after generating the new certificate?

sudo /opt/bitnami/ctlscript.sh restart apache

We have a Support Tool that will gather relevant information for us to analyze your configuration and logs. Could you please execute it on the machine where the stack is running by following the steps described in the guide below?

Please note that you need to paste the code ID that is shown at the end.

Hi,

Yes sir, the main domain is opticaconfortcenter.com, and yes i restart apache too.

The code id:
3e70cbb3-85db-15f6-b53e-16eee1bed23d

Thanks,

Hi @aaldanap92,

I just found the issue in the configuration, you have 2 VirtualHost blocks in the apache2/conf/vhosts/prestashop-https-vhost.conf.

<VirtualHost 127.0.0.1:443 _default_:443>
  ServerAlias *
  SSLEngine on
  SSLCertificateFile "/opt/bitnami/apache/conf/opticaconfortcenter.com.crt"
  SSLCertificateKeyFile "/opt/bitnami/apache/conf/opticaconfortcenter.com.key"
...
</VirtualHost>
<VirtualHost *:443>
    ServerName yaveo.co
    ServerAlias yaveo.co
 SSLCertificateFile "/opt/bitnami/apache2/conf/yaveo.co.crt"
  SSLCertificateKeyFile "/opt/bitnami/apache2/conf/yaveo.co.key"
...

The second VirtualHost has the ServerName and ServerAlias parameters configured, but the first one matches everything (you are using asterisk) and that’s why yaveo.co uses the opticaconfortcenter.com certificate. You will need to modify the first VirtualHost to be like this

<VirtualHost 127.0.0.1:443 _default_:443>
  ServerName opticaconfortcenter.com
  ServerAlias opticaconfortcenter.com
  SSLEngine on
  SSLCertificateFile "/opt/bitnami/apache/conf/opticaconfortcenter.com.crt"
  SSLCertificateKeyFile "/opt/bitnami/apache/conf/opticaconfortcenter.com.key"
...
</VirtualHost>
<VirtualHost *:443>
    ServerName yaveo.co
    ServerAlias yaveo.co
 SSLCertificateFile "/opt/bitnami/apache2/conf/yaveo.co.crt"
  SSLCertificateKeyFile "/opt/bitnami/apache2/conf/yaveo.co.key"
...

Something similar happens in the apache2/conf/vhosts/prestashop-vhost.conf file and you will also need to set the servername and serveralias parameters

Note: You have duplicated content in the apache2/conf/vhosts/prestashop-vhost.conf that you can safely remove

Happy to help!


Was my answer helpful? Click on :heart:

Thanks a lot for your help, but there’s a new problem.
Now i have both certificates but, the installation disappear.
The only message is It works! Look, https://yaveo.co/

It’s a multistore on prestashop, i mean two domains on the same instance.

I solve it, it was missing the directory root to the code.

Hi @aaldanap92,

I’m glad to hear that you managed to solve the issue :tada:

Enjoy :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.