Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-domain https redirect

I have a question regarding redirecting https requests.

Background

  • Drupal multi-site administered via Aegir
  • Apache server
  • Shared IP; dynamic host-name resolution

The situation

I have a user with two domains pointing to the same site: foo.com and bar.com. Through Aegir, I am forwarding foo.com to bar.com. Requests for http://foo.com redirect to http://bar.com with no problem. The user also has a SSL that only covers bar.com, but not foo.com.

The question

On Apache (or, through Aegir) is it possible to forward https://foo.com requests to https://bar.com without throwing a certificate warning? Currently, anyone who makes a request to https://foo.com receives a certificate warning.

Many thanks for any expertise you can share!

like image 351
Beau Townsend Avatar asked Dec 11 '25 20:12

Beau Townsend


2 Answers

No it's not possible.

When a browser requests a https site, the browser does the SSL negotiating first, and then handles the request (in this case returning the redirect).

So you need to have a valid cert for foo.com to pass that first stage.

like image 159
Barry Pollard Avatar answered Dec 13 '25 11:12

Barry Pollard


Yes it is possible. There is the self-sufficient way and the easy way. :)

  1. Self sufficient way

Set up Let's Encrypt to automatically get an SSL certificate for foo.com on the machine that is running appache. You can now enable HTTPS for foo.com and have it forward both HTTP and HTTPS requests to bar.com

  1. Easy way

Use the free forwarding service https://redirect.pizza. They basically do the above for you. You tell them where to forward foo.com and then point foo.com DNS to them.

DISCLAIMER: I have nothing to do with redirect.pizza, I just really like their service. I was going to build the exact same service when I got frustrated that godaddy.com does not offer something like this, but then (luckily) found them and they did it perfectly to saved me the effort.

like image 32
bigjosh Avatar answered Dec 13 '25 11:12

bigjosh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!