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.

Attempting to get my site to comply with the limitations of an edge content delivery network, I have been forced to push my security certificate root from https://www.mysite.com to the subdomain https://www.secure.mysite.com . I am now contemplating what seems to be a novel way I can mirror the content from my nonsecured domain through my secure subdomain. Utilizing several mod_rewrite commands in my apache configuration, I have successfully set it up to redirect all https://*.com requests to my server to prefix the request to https://secure.*.com.

Now here comes the part I wanted to invite some discussion on. This is my outline for my idea.

Unlike the rest of my server, any request through the secure subdomain will be handled with a different ErrorDocument for 404 requests. Instead of simply displaying a 404 error, this page will be responsible for trying to find an eligible 'proxy' point on the base domain. Here's an example:

  1. The user requests https://mysite.com/site/walrus.php?cool=1
  2. The mod_rewrite changes the original request to https://secure.mysite.com/site/walrus.php?cool=1
  3. The server is unable to find /site/walrus.php in the secure subdomain, and it invokes the 404 handler for the secure subdomain
  4. The 404 ErrorDocument (a php script) strips the secure part out of the requests, rendering http://mysite.com/site/walrus.php?cool=1 again
  5. The script attempts to use file_get_contents() to get the contents of http://mysite.com/site/walrus.php
  6. If the script finds http://mysite.com/site/walrus.php is an existing resource, it echoes the contents of that file as its own contents. Otherwise, having been unable to find the resource, it proceeds to issue redirect headers to the normal 404 ErrorDocument that applies to the rest of the server.

So, what comments can you make about this? Has it already been done before, are there resources or examples of this kind of thing for me to look at while I do this?

share|improve this question

1 Answer 1

Judging by your question what you seem to want is https://secure.mysite.com/* --> https://www.mysite.com/*

If that's the case why not simply go with the ghetto solution of configuring your web server to handle multiple hostnames (ServerAlias in Apache), point both domains at the same IP, and configure the SSL certificate for secure.mysite.com.

Yes, someone could theoretically hit your main site as https://www.mysite.com and get a SSL error (Certificate Name Mismatch), but this requires no configuration maintenance or gnarly rewrite rules -- it's much nicer for your server.

share|improve this answer

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.