-1

I have a site www.example.com running on a hosting company.

Now I want to create a separate web app on my VPS and let it accessible via app.example.com

How can I set the DNS to redirect app.example.com to my VPS' ip address? CNAME or A Record?

Also, If I want to do a mail server on my VPS too, how to setup the DNS?

EDIT:

Existing site: www.example.com
Location: some hosting company that I don't control. It's running PHP with nginx I guess (or aphache)

New site (that I'm working on): app.example.com
Location: my VPS, it has an IP address, the VPS is running nodejs. It can run along with nginx but currently it's not.

I want the existing website continue working (as customer visit www.example.com) and I want customer to visit app.example.com for some new features.

The two websites are NOT on the same server and not using the same IP address.

1
  • Do you have access to the DNS control panel for this domain? If not, you will need to ask whoever does to do this for you.
    – Ladadadada
    May 31, 2014 at 6:49

2 Answers 2

3

The question is unclear as to whether www.example.com is hosted on the VPS or not.

If www.example.com is not hosted on the VPS then it is irrelevant. You create app.example.com as an A record pointed at your VPS, or app.example.com as a CNAME of the machine name of the VPS if its a publicly resolvable A record.

If www.example.com is hosted on the VPS and is an existing A record, you could create a CNAME pointing app.example.com at www.example.com. You would have to set appropriate bindings on your web server software that the sites get served properly.

CNAME is essentially an alias. The advantage of using it is if there are multiple DNS records for a single host you only have to update one record (the A record) if the host IP changes.

For your mail you setup MX DNS records- just point them at your VPS and configure your mail server software.

EDITED because the question is a little vague.

6
  • But I read I cannot use CNAME with ip address? link
    – AZ.
    May 30, 2014 at 21:54
  • That's what I said, and he wants a separate site on his VPS
    – squillman
    May 30, 2014 at 22:44
  • @AZ - you cannot point a CNAME at an IP. CNAME is an alias to an existing host name.
    – bkr
    May 30, 2014 at 22:47
  • @squillman I have edited my answer to try make it more clear but the question is still vague.
    – bkr
    May 30, 2014 at 23:00
  • @bkr the existing site is NOT on the VPS. So sounds like I can just create a A record from app -> VPS IP?
    – AZ.
    May 31, 2014 at 0:41
0

First of all, you should add a lot more info to your question, like, are you using Apache, Centos? red Hat, a Windows server? which version of Bind, etc, tec.

Anywyay I will suppose you are using a linux vps with apache

Using a VPS has its complications. I suggest you pay the extra USD 5 for a WHM/Cpanel license (depending on your provider)

Anyway, the DNS has nothing to do with the app.example.com <=> www.example.com

Both sites share the same ip, you have to create a differente virtual host in Apache, one for www.example.com with a ServerAlias example.com and another virtual host for app.example.com.

2
  • Sorry for the confusion. I just edited my question. They are not on the same server and not using the same IP
    – AZ.
    May 31, 2014 at 0:38
  • Ok, so you have to edit you DNS zone by yourself and add an "A" record. If I were you, I would use cloudflare.com, I find it easier to use and very powerful. Theres a free account you can do almost everything May 31, 2014 at 15:58

Not the answer you're looking for? Browse other questions tagged .