-4

We maintain links to the documents coming from the following 3 sources.

1. docs.abc.com
2. docs.def.com
3. docs.ghi.com

But we do not give a direct link to the user. So we give the links to the documents, like the following.

docs.mysite.com/abc/other-link-info

docs.mysite.com/def/other-link-info

docs.mysite.com/ghi/other-link-info

So when user's browser tries to access the link, browser hits our site docs.mysite.com and we have two approaches on how to serve the documents.

Approach 1: For each link, we will compute the actual link (source link) of the document and download the document from the source link. We will then stream the document to user.

The downside of this approach is that there is a load and bandwidth usage on the server.

Approach 2: Create 3 CNAME aliases, the following way so that the documents are served automatically.

docs.mysite.com/abc => docs.abc.com
docs.mysite.com/def => docs.def.com
docs.mysite.com/ghi => docs.ghi.com

The advantage is that there is no load and bandwidth usage on the server. But I am not sure whether this approach is possible.

One side question: If we create a CNAME alias like docs.xyz.com pointing to mybucket.s3.amazonaws.com, does the end user gets to know the source link or where we stored our documents. We do not want the end user know where we stored the documents, and a lot of times those documents are not ours.

Another side question: If we have a CNAME alias like docs.xyz.com pointing to mybucket.s3.amazonaws.com, can we MX records and other records on xyz.com domain?

Thank you very much for taking time to read this.

dotcoder
  • 115
  • 1
  • 5
  • 1
    This question is not DNS related. – Esa Jokinen Mar 04 '15 at 23:33
  • Can you tell me what is this related to and I will tag it appropriately? – dotcoder Mar 04 '15 at 23:40
  • This is related to web servers and http redirects. With DNS records you cannot affect on how the target site will handle the requests. – Esa Jokinen Mar 04 '15 at 23:47
  • No, I am not talking about how the target site handles the requests. I am talking about how my site needs to handle and possibly with the help of DNS CNAME aliases. If you have given a down vote, it is not helping my genuine question. – dotcoder Mar 04 '15 at 23:56
  • 1
    With CNAME record the browser will ask mybucket.s3.amazonaws.com to server pages from domain docs.xyz.com which it doesn't recognize at all, so this is not DNS related question and CNAME records doesn't offer any solution to the use case described. – Esa Jokinen Mar 05 '15 at 00:00
  • As it stands this question is on its way to being closed because it will not be useful to future readers. (it's based on a mistaken premise) I recommend that you restructure this around what you are trying to achieve and the solutions that you have tried so far. The CNAME rabbit hole is a dead end. – Andrew B Mar 05 '15 at 00:19
  • CNAME is NOT an HTTP redirect. Why oh why do people think it is??!?!? – Joe Sniderman Mar 05 '15 at 05:24
  • Questions must demonstrate a **minimal understanding of the problem being solved**. Try including attempted solutions, why they didn't work, and the *expected* results. See [How can I ask better questions on Server Fault?](http://meta.serverfault.com/q/3608/118258) for further guidance. – HopelessN00b Mar 05 '15 at 06:24

3 Answers3

2

No, this will not work. DNS is protocol agnostic. You can setup a webserver to take those, and redirect to the link you want to send your users to.

Jacob
  • 9,114
  • 4
  • 44
  • 56
1

As explained, this cannot be achieved via DNS settings.

But your approach #1 can be improved by making the docs.mysite.com server cache the files that it retrieves from the origin server, and serve those cached files from its own storage.

With nginx you can use proxy_cache to establish caching of the proxied content from the origin servers.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58
  • I was 90% convinced that I had to go with the approach #1, but only problem is it is resource intensive and consumes bandwidth. I posted to this forum to see whether brilliant people out here can provide some insight to improve my solution. As it turns out, this is no other way. It is pretty discouraging how people convey this. Thank you for your time. – dotcoder Mar 10 '15 at 13:21
1

No, you cannot. That is very simply not what a CNAME does.

foo.example.com. can be CNAME

http://foo.example.com/ cannot be a CNAME

http://foo.example.com/bar cannot be a CNAME

CNAME aliases one DNS label to another. A URL is NOT a DNS label. And for the record, a URL is NOT a domain.

Joe Sniderman
  • 2,749
  • 1
  • 21
  • 26