Jason Mirk
Jason Mirk

Reputation: 313

How do I redirect a CNAME to an IP on azure?

I have a docker VM on azure that gave me an IP address. I have my A record set to this ip and everything works fine.

Now I want to move that to a subdomain and have my main domain to to github pages. How do i do that? If I create a webapp azure creates a cloudapp.net domain for me but with the docker VM i dont see how to get that.

Upvotes: 0

Views: 1065

Answers (1)

Michael B
Michael B

Reputation: 12228

Your question is a little vague on exactly what you're wanting to achieve, so I'll try to cover the obvious solutions.

Firstly, you can't direct an CNAME to an IP Address, if you need to point something to an IP then you would use an A record. You can then point a cname to that A record.

So you could have

;;Example.com
www         A         192.168.0.1
docker      CNAME     www.example.com 

For github you can either have an A record pointing to their IP Addresses.

;;example.com
www        A         192.30.252.153
www        A         192.30.252.154

If you just want example.com directing to github, you would use

;;example.com
@        A         192.30.252.153
@        A         192.30.252.154

If you want to use a cname for github, you can use

;;example.com
www       CNAME         username.github.io

This still leaves you to configure things on the github side - see this document

As for the docker machine.

I'm presuming you don't actually want a subdomain i.e. www.docker.example.com, but instead you want docker.example.com - If I'm wrong about say so in comments

If you have a reserved IP address configured for your docker instance, it is simply a matter of directing an a record from the name you want to that IP address

;;Example.com
docker         A         192.168.0.1

A better way though, is to create a cname to the cloud service hosting your docker server, if you are using v1 domain names, or the domain name attached to your public IP address if you're using v2 (resource manager). By creating a cname you don't need to be concerned about the IP address changing, because the cname will always keep track.

To do this, it is exactly the same as above, with the appropriate parts filled in

For v1 (as documented here)

;;Example.com
docker      CNAME     <Yourhostname>.cloudapp.net 

For v2

;;Example.com
docker      CNAME     <Yourhostname>.<region>.cloudapp.azure.com

Hopefully there should be enough there to get you started! Or at least to be able to ask a question to get what you actually require.

Upvotes: 2

Related Questions