1

On my VPS server with cPanel/WHM, I have 2 accounts: domain1 and domain2.

Each of these domains are the main domains for their accounts. Meaning that domain1 has other alias domains as well, and domain2 has also some additional alias domains. The ip of these accounts is different. Meaning that domain1 has one ip and domain2 has it's own ip.

For domain1, I've added a DNS A record that points to domain2's ip. Now, when accessing domain1, the website from domain2 is served as expected because of this "redirection", which is what I want.

Both of these domains, have also SSL valid certificates for their own domains and alias domains.

The problem is that when I access domain1 and the website from domain2 is returned, the SSL certificate from domain2 is also returned, which of course does not cover the domain1, meaning that the connection is marked as unsecure.

I've checked with 'whynopadlock.com' and the result was the expected one: the SSL certificate is valid indeed, but since it belongs from domain1, it does not provide coverage for domain2 as well.

Therefore, how can I fix this SSL issue?

Please note that this behavior was successfully working on my previous server, but I had to migrate it to a new server where it doesn't work anynore and I don't know how it did worked on the previous server. One thing for sure is that there was no multi domain SSL certificate, but everything worked by default using AutoSSL and SSL certificates provided by Let's Encrypt for free.

cPanel/WHM doesn't let me to add domain1 to the domain2's account, because it's already in use.

I don't want to move domain1 to domain2's account for other reasons. I want to keep them separate as they are, but just to fix this SSL error.

1 Answer 1

1

You need to implement the redirect in domain1's account.

  • Use a DNS A record to point domain1 to domain1's IP address rather than to domain2's IP address.

  • Use cPanel/WHM to get a certificate for domain1 under domain1's account.

  • Implement a redirect in .htaccess in domain1's document root.

    Redirect permanent / https://domain2.example/
    

    If you want to show the content from domain2, then you will need a reverse proxy rule:

    RewriteEngine On
    RewriteRule ^(.*)$ https://domain2.example/$1 [L,P]
    ProxyPassReverse / http://domain2.example/
    

That way domain1 will work, even with HTTPS.

7
  • Thank you for your message Stephen. But is this going to keep the domain1 in the browser? Because I don't want to be redirected to domain2. User should see that he's on domain1, no matter what's happening behind. Commented Dec 25, 2023 at 1:21
  • I've added a proxy rule that you can use, but I question why you would want to do that. Showing the same content on two different domains is not recommended for SEO. Commented Dec 25, 2023 at 1:34
  • 1
    If you were willing to move domain1 to domain2's account, you could have domain2 get a certificate for both of them. I don't know your reason for wanting them separate, but I would usually prefer to do that over using a reverse proxy. Commented Dec 25, 2023 at 1:36
  • The web application that runs on domain2 is actually prepared to show different content depending by the incoming domain name. Therefore, will be one website when accessing from domain1 and another website when accessing from domain2. That's basically the source app. The reason for separating the domains in different cPanel accounts is about email filtering, but that's another story. Will try now your solution. Thank you for now. Commented Dec 25, 2023 at 1:44
  • I've updated the A record to domain1 and website from domain 1 returned, as the DNS has been propagated. Then, added the configs to .htaccess, but I got an Internal Server Error: ".htaccess: ProxyPassReverse not allowed here" .Therefore, I've extracted the virtualhost code from /etc/apache2/conf/httpd.conf, added the snippet from you for the reverse proxy and added the whole <VirtualHost> block in post-virtualhost include section of Apache configuration in order to overwrite the default configs. Now, the website for domain2 is loaded again, so the reverse-proxy works, but I still get SSL error Commented Dec 25, 2023 at 2:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.