I went to the domain registry and add the A record to .mysite.com with IP address, and dev.mysite.com and rest.mysite.com with the same IP Address.
Then in node, I have this:
server.use(express.vhost('rest.mysite.com', restApp)).
use(express.vhost('mysite.com', webApp)).
use(express.vhost('dev.mysite.com', webApp)).
use(express.vhost('www.mysite.com', webApp));
But I can only see the page from mysite.com and www.mysite.com, not rest.mysite.com nor dev.mysite.com.
What else do I need to set up?
do I need to change the server (ubuntu) host entry as well? but I have done it in this way already:
127.0.0.1 localhost
127.0.0.1 rest.localhost
what else do I need to do?
============== After almost 6 hours, I finally get rest.mysite.com working. it is the DNS that takes very long time to propagate...
but now, another question. do I have to set up each subdomain or sub-subdomain in DNS?
I tried this for DNS A record setting: ".rest.mysite.com"
and in node, I add express.vhost('dev.rest.mysite.com');
but it doesn't work. do I need to set dev.r开发者_开发知识库est.mysite.com in the DNS?
I got it working now. use *.rest.mysite.com for the A record, and then I can use the node to make the subdomain. :)
You had to wait for the DNS to propagate because your hosts file was wrong.
If there is an entry in your hosts file, your computer uses that, otherwise it uses DNS, so you could have set your hosts file to
127.0.0.1 localhost rest.mysite.com dev.mysite.com www.mysite.com
and then you could have been trying it without worrying about DNS propagation. Of course, as soon as you want other people to be able to look at the site, you will need to change the DNS, and at that point you probably want to remove the host entry too.
It's better to close this question and ask another one.
You can try to set '*.rest.mysite.com' in DNS. But depending on your DNS control panel it may or may not work.
Also, bear in mind that it's better to setup only one A record and make CNAME records for aliases.
精彩评论