Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

closed as off-topic by Iain, kasperd, Cristian Ciupitu, mdpc, dawud Jun 1 at 8:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "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? for further guidance." – Iain, kasperd, Cristian Ciupitu, dawud
If this question can be reworded to fit the rules in the help center, please edit the question.

    
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 at 6:49

2 Answers 2

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.

share|improve this answer
    
But I read I cannot use CNAME with ip address? link –  AZ. May 30 at 21:54
    
That's what I said, and he wants a separate site on his VPS –  squillman May 30 at 22:44
    
@AZ - you cannot point a CNAME at an IP. CNAME is an alias to an existing host name. –  bkr May 30 at 22:47
    
@squillman I have edited my answer to try make it more clear but the question is still vague. –  bkr May 30 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 at 0:41

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.

share|improve this answer
    
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 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 –  Alejandro Angelico May 31 at 15:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.