Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I currently use a CNAME to silently direct all traffic for http://cdn.domain.com to my Rackspace Cloud Files domain at http://cxxx.rxx.cxx.rackcdn.com.

Now I also want to silently direct all HTTPS traffic for https://cdn.domain.com to https://cxxx.ssl.cxx.rackcdn.com.

I assume I can't do this using CNAME (if I can, bloody excellent!) so I'll be using VirtualHosts, as such:

<VirtualHost *:80>
    ServerName cdn.domain.com
    RewriteEngine On
    RewriteRule ^(.*)$ http://cxxx.rxx.cxx.rackcdn.com [L,R=301]
</VirtualHost>

<VirtualHost *:443>
    ServerName cdn.domain.com
    RewriteEngine On
    RewriteRule ^(.*)$ https://cxxx.ssl.cxx.rackcdn.com [L,R=301]
</VirtualHost>

Will I need an SSL certificate for the second vhost, or will it "borrow" it from Rackspace's HTTPS domian?

share|improve this question
add comment

2 Answers

You will need a certificate for cdn.domain.com.

You can't use a CNAME because when the browser gets the cert for cxxx.ssl.cxx.rackcdn.com instead of cdn.domain.com, it'll throw up an error because the cert doesn't match the URL you put in. And when doing a redirect within apache, the redirection is happening after the SSL session is established (and the cert is needed to establish that SSL session).


Another solution would be to provide an alt name in the certificate for cxxx.ssl.cxx.rackcdn.com. Basically the cert would contain both cxxx.ssl.cxx.rackcdn.com and cdn.domain.com. You then could use a CNAME since the same cert is valid for both host names (URLs).

share|improve this answer
    
Thanks for clearing that up, much appreciated! –  Will Aug 9 '12 at 12:36
    
Indeed a great answer, and the same as I tried to say - just better :) –  Frederik Nielsen Aug 9 '12 at 12:37
add comment

You will need one for your subdomain, as all that subdomain does is to redirect visitors.

I am pretty sure you can't do this with CNAME.

Another way to do it, is to redirect data from the HTTP connection to the HTTPS rackcdn connection like this:

<VirtualHost *:80>
    ServerName cdn.domain.com
    RewriteEngine On
    RewriteRule ^(.*)$ https://cxxx.rxx.cxx.rackcdn.com [L,R=301]
</VirtualHost>
share|improve this answer
    
Won't I then get insecure items errors if I use the following on a secure page... <script src="http://cdn.domain.com/widget.js"></script> –  Will Aug 9 '12 at 12:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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