0

My goal is:

*a.example1.com* should point to *example2.com/test*

Data:

  • The hosting machine for example2.com has the SSL certificate (wildcard) *.example2.com
  • I manage both domains.

Solutions I thought of:

  • Creating a subdomain test.example2.com pointing to content under '/var/www/site/test'. (subdomain should point to the same machine)

  • Create a CNAME record as such: a.example1.com CNAME test.example2.com

Problem:

This will cause an SSL certificate issue on the browser. So, I need to install the SSL certificate for a.example1.com on the host machine for example2.com and more precisely on the virtual host test.example2.com. However, I am not sure this is even possible? I found this source on how to have two virtual hosts in apache with two different domains and therefore with different SSL certificates: So If I do the following:

  • Create a virtual host for test.example2.com --> pointing to '/var/www/site/news' and having the wildcard certificate '*.example2.com'

  • Create another virtual host for a.example1.com --->pointing to /var/www/site/test and having the wildcard certificate 'a.example1.com' (on the same machine)

  • And Created the following record:

    a.example1.com CNAME to test.example2.com

Would that solve my problem?

  • You can't CNAME to a URL like /test anyways. Why do you want to CNAME instead of having two A records and two virtualhosts? – ceejayoz May 15 '17 at 21:52
  • The web server doesn't know whether you were using A or CNAME (however, if you need MX etc. for mail, you'd definitely want to use A). On the webserver you could a) enable SNI and get certificate for both domains b) get a multidomain certificate c) redirect both from HTTP to HTTPS on the one that already has certificate, possibly to a different subdomain. – Esa Jokinen May 15 '17 at 23:03
1

From your DNS example, you would have:

test.example2.com IN A 1.2.3.4
a.example1.com IN CNAME teste.example2.com

This basically means that your client will resolve a.example1.com to the ip 1.2.3.4. It also means that your web-server on 1.2.3.4 ( as you said, Apache ) will receive requests for both URLs, and Apache is smart enough to send the GET/POST etc., to the right place.

With segregation in your virtual hosts entry's (can even be on the same file), you can handle a lot of different URLs and domains. I particularly have more then 200 vhosts files ( not that smart ) on one single Apache (moving to HAproxy due performance issues). So yes, having two completely different URLs on the same server would definitely work. Just watch out for proper TLS configuration ( like using the right key and cert, etc ).

[]`s

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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