10

I recently deployed an Windows Azure application and configured DNS of my domain through DreamHost portal. Now my site is accessible through http://www.coziie.com, but not through non-www address.

I read in one of the articles that I should add an A record in DNS settings and point to virutal IP of Windows Azure. How do I get virutal IP of my Windows Azure deployment?

Or is there any better way to 301 redirect all non-www urls to www?

RESOLVED: I was able to solve this problem by simple configuring a website redirect settings in DreamHost DNS settings. A simple 301 redirect of http://coziie.com to www.coziie.com sorted out the issue.

Gopinath
  • 1,858
  • 7
  • 31
  • 50
  • If you don't want to deal with this problem yourself, you can use a service like [DNS Azure](http://www.dnsazure.com/) that exists purely to solve this problem. For a fee of course. – knightpfhor Jul 20 '11 at 21:29

3 Answers3

15

You are talking about two separate issues here.

The first is to setup a DNS record so that your un-canonised url works. The second is to redirect the url if the site is accessed by it.

update I have removed the previous advice for CNAME from here as I didn't realise before that you cannot set the root domain to a CNAME record. It seems that with the ip restrictions of Azure you will have to point the root domain record at non-azure, asp.net hosting and then put a 301 redirect (such as the one further down my reply) to forward it on to the Azure domain (www domain).

When you have http://coziie.com/ pointing at your site and serving the page its then time to fix this because Google can get confused, think its two different sites and then dilute your page rank between the two.

The trick is to set up a 301 redirect. I believe the url rewriting tool started out as an addon for IIS7 but is now included in it? You might have to do a quick search on that.

Anyway, this is how I do it on an IIS7 server with the official url rewrite extension installed (this goes in your web.config):

  <system.webServer>
    <rewrite>
      <rules>
        <clear/>
        <rule name="WWW Rewrite" enabled="true">
          <match url="(.*)"/>
          <conditions>
            <add input="{HTTP_HOST}" negate="true" pattern="^www\."/>
          </conditions>
          <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent"/>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

Intellisense will complain that its not a recognised element but thats just a cosmetic issue while you are editing the file.

rtpHarry
  • 13,019
  • 4
  • 43
  • 64
  • rtpHarry, seems to be the IP address of a site on Azure is not going to be static. MSDN article[link](http://blogs.msdn.com/b/windowsazure/archive/2011/07/06/windows-azure-deployments-and-the-virtual-ip-address.aspx) says that "A VIP is associated with the deployment and not the hosted service. When a deployment is deleted, the VIP associated with that deployment will return to the pool and be re-assigned accordingly, even if the hosted service is not deleted. Windows Azure currently does not support a customer reserving a VIP outside of the lifetime of a deployment." – Gopinath Jul 19 '11 at 15:03
  • As the IP address is not static(as per my understanding) how to create a A record? – Gopinath Jul 19 '11 at 15:05
  • Ok sorry it seems you need to setup a `CNAME` not an `A` record. This is basically the same thing only you point a `CNAME` at a domain instead of an IP. Looking at your record it shows thats what you have done for the www: `www.coziie.com. 14400 IN CNAME coziie.cloudapp.net.` I would set the same `CNAME` up for your non-www record. – rtpHarry Jul 19 '11 at 16:11
  • My DNS setting panel showed the error "CNAME records may only be used on sub-domains." when I tried to create CNAME for coziie.com and point it to coziie.cloudapp.net. Am I missing something? Are the CNAME's only for sub domain? – Gopinath Jul 19 '11 at 16:25
  • I didnt realise that was a restriction but it seems [youre right](http://stackoverflow.com/questions/656009/how-to-overcome-root-domain-cname-restrictions). Doing a [bit of research](http://social.msdn.microsoft.com/Forums/en-US/windowsazuremanagement/thread/aed5318f-7d8e-4693-8c83-24f34b36df9e/) it seems azure doesn't support this. – rtpHarry Jul 19 '11 at 16:31
  • @Gopinath let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/1634/discussion-between-rtpharry-and-gopinath) – rtpHarry Jul 19 '11 at 16:32
  • updated my answer again as stackoverflow doesn't like us talking this much in comments – rtpHarry Jul 19 '11 at 16:37
0

The VIP address is easily obtained by either looking at the portal (read deployment details) or by simply pinging your .cloudapp.net address. You can set an A record, but you must be prepared to update that in case you delete your deployment. Once you delete a deployment, the VIP address will be returned to the pool and there is pretty much a guarantee that you will get a new VIP address on the next deploy.

You can maintain your VIP address by using the Upgrade feature as opposed to new deployments. There are some limitations to this, but it works for updates that do not change the Service Definition broadly speaking.

We used to say that the VIP address was not guaranteed even if you did an update, but MS has come back with stronger language about guarantees. See here.

dunnry
  • 6,858
  • 1
  • 20
  • 20
  • VIP address does not look like a good option. On every deployment, it forces us to update the DNS records. If we miss to update the DNS, we will end up with loads of broken url. – Gopinath Jul 19 '11 at 17:04
  • If you want an A record, this is your only option. You can do a forwarding thing from some DNS operators (like Godaddy), but that will forward to a CNAME. Your only hope for domain.com (A record) is what I have said right now. – dunnry Jul 20 '11 at 12:10
0

CNAMES are only for subdomains, like sub.example.com or www.example.com, you can't register a CNAME for example.com in other words. If your domain provider supports it you could create a redirect from example.com to www.example.com and then create a CNAME record for www.example.com, the CNAME will match www.example.com against example.cloudapp.net. My domain provider has a web console where I can do this easily, perhaps yours have too?