Setup Virtual Host
Buy a Linode instance on linode. Note its IP address on the home page in your user account. Install a Linux system and secure it.
Ref: Getting Started for instructions.
To build a new VPS, in Linodes -> Rebuild, select OS ("Ubuntu 14.04 LTS" for now), set root password, and click "rebuild" button, it will create disks and configuration profile automatically. Then click "boot" button under configuration profile. After system startup (see progress in "Dashboard -> Host Job Queue"), Connect to the VPS with SSH according to commands in "Remote Access".
Or you can create disks, then configuration profile manually in "Dashboard". Create new disks under "Disks", usually a boot part (3GB), a home part and a swap (same capacity with memory).
Connect domain name and IP address
Here we link multiple Domain names to the same IP address. Then direct different domain requests to its corresponding port using nginx.
First register (purchase) a domain name, if you haven’t already. Here I used niufairs.com and "niufairs.cn purchased on net.cn.
Set IP address in "进入会员中心 -> 我的域名 -> niufairs.com -> 域名解析 -> 解析设置 -> 设置网站解析 -> 把域名指向我的网站-添加IP地址", add your Linode instance IP address as "A" record, Then wait up to 24 hours for the changes to take effect. I waited about 30 minutes to take effect.
Next set your domain name to use Linode’s name servers ("ns1.linode.com" to "ns5.linode.com") in "我的域名 -> niufairs.com -> 基本管理 -> DNS修改/创建 -> DNS服务器 -> 修改域名DNS".
On Linode, come to "DNS Manager" in Linode dashboard, click "Add a domain zone". Set "Domain" as your purchased domain name, for example, "niufairs.com". Set "SOA Email" the email address of the administrator, for example, "lc@126.com". Then click "Add a Master Zone".
Setting Reverse DNS
On linode instance dashboard -> Remote access -> Reverse DNS, enter "niufairs.com", and press "Look up".
Ref: Hosting a website.
Config Relationship betwwen domain and port
Fist install nginx (with aptitude on Ubuntu).
Edit /etc/nginx/nginx.conf as follows:
events {
worker_connections 1024;
}
http {
server {
server_name niufairs.cn;
location / {
proxy_pass http://localhost:3000/;
}
}
server {
server_name niufairs.com;
location / {
proxy_pass http://localhost:4000/;
}
}
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
}
Test if this conf is right: nginx -t
;
If test ok, reload conf: nginx -s reload
;
Now start 2 meteor app on port 3000 and 4000, and you can use niufairs.cn and niufairs.com to visit them respectively.
If you want server some static files, add a new "server" section in "http" of nginx.conf:
http {
server {
server_name newfairs.cn;
location / {
root /data/www;
}
location /images/ {
root /data;
}
}
server {
...
}
}
Configure Email Server
I bought an business account on FastMail, and configure 3 places to make the mail server functional:
-
In FastMail masteruser@niufairs.com account, add "niufairs.com" in "Domains" section in "Manage" panel.
-
Add the following record on net.cn (website's registrar):
记录类型: MX, 主机记录: @, 记录值: in1-smtp.messagingengine.com, MX优先级: 1, TTL: 10分钟.
-
Add the following record on "niufairs.com" on Linode.com:
MX Records -> Mail Server: in1-smtp.messagingengine.com, Preference: 10, TTL: Default.
Refs: