Sub domain mapping in windows azure

最后都变了- 提交于 2019-12-04 07:45:13
Stuart

Just to assist a bit on the other answers.

Azure's main mechanism for routing requests to your instance is to use "CNAME" DNS records - http://en.wikipedia.org/wiki/CNAME_record.

These CNAME records basically tell the clients (browsers) that www.mydomain.com is an alias for myapp.cloudapp.net

Sadly you cannot CNAME a wildcard Depending on your DNS host you may not be able to wildcard CNAME records (see https://serverfault.com/questions/44618/is-a-wildcard-cname-dns-record-valid), so in order to map multiple subdomains to the same Azure instance, then you may need to set up multiple CNAME records - one for each subdomain you want to reroute - i.e. when you sign up customer "new", then you need to add a new CNAME record mapping "new.mydomain.com" to myapp.cloudapp.net

The two suggestions from Joannes and jmac both suggest external services for setting up those mappings. For some other options - and some Amazon C# sample code - see this post http://computerone.co.nz/community/discussion/29/amazon-route-53-dns-request-in-c-using-the-rest-api/p1 (there's also an affordable C# library available on http://www.proactiveit.co.nz/Route53/R53Connect/)

Being able of generating many subdomains linking to a Windows Azure web role is a matter of programmatic reconfiguration of a DNS rather than a matter of web role configuration.

Amazon offers a cloud-based DNS service named Amazon Route 53 that you could use for this purpose. It would work with Windows Azure actually.

Then, within your webrole, you would need to apply some ASP.NET tweaks to grab the host header of the initial web request to grab the actual subdomain being browsed by your users.

We avoid the need to create a DNS CNAME record for each "Space" by using DynDns Custom DNS to create a wildcard CNAME record that routes all subdomain requests (*.ourdomain.com) to a web role. If you decide to go this route, your web role will parse out the subdomain of the incoming request to lookup a user's "Space".

From the DynDns documentation:

Alias (CNAME) Records

CNAME records alias one host name to another. For example, many customers alias www.domain.com to domain.com; this ensures that both www.domain.com and domain.com are always assigned to the same IP address. CNAME records in Custom DNS take the following options:

As with host (A) records, the Hostname field is restricted to allow only the characters A thru Z, the digits 0 thru 9 and the hyphen (-). The Hostname field can use an asterisk (*) to generate a wildcard CNAME record. (The Hostname field cannot be left blank, as RFCs prohibit second-level CNAME records.)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!