Adding secondary domain multi-site configuration Ali cloud

Add secondary domain name

After you purchase your own domain name, you will want to use the second-level domain to define a new site. For example blog.ryanzheng.com station is blog, www.ryanzheng.com as the main station, bbs.ryanzheng.com as a forum stations and so on. So how to set up your own secondary domain name it?

First of all, we came to Ali cloud domain DNS management panel

 

 

 

 

 

 

We see record types A and CNAME type, First we come to know about them (the other types we can inform themselves about)

1. What are A Record
A record is IP resolution, direct the domain name to point to a IP, if the IP is subject to change, then A record there must also be changed.


2. What is a CNAME alias resolution
CNAME is an alias resolution, an alias DNS resolution is the first to jump to sub-host alias IP, IP hosts such changes without re-parsing.


The main difference 3.A CNAME record and the
effective time a.cname resolved faster than the A record, A record often take several hours to 48 hours, cname few minutes
b. If the record is A, IP host once occurred changes, it must re-parsed; if cname is resolved, you do not need to re-parsing.


4. When using an A record, CNAME alias when parsing with
frequently changing IP, recommended for analyzing the CNAME aliases, not often change IP, recommended A record resolves directly to the IP.
Multi-line space, must be resolved with a CNAME aliases.

Note: It is said that Baidu prefer to make the site an A record pointing to IP, if you use the top-level domain A record, second-level domain with the www CNAME aliases resolution, then, Baidu will think that this is two stations instead of one station. In other words, A Baidu SEO optimization recording easy. But this remains to be verified.

To put it plainly, is to point directly to A, CNAME indirect point

So back to focus, how to set up the secondary domain name?

We add a record, first with the CNAME to point to the blog subdomain, such as:

 

 

这样的话,blog.ryanzoe.top 指向的还是A所指向的IP地址,当然CNAME可以指向其他的别名,如xxx.domain.xxxxxx这种形式的

还可以使用A直接指向IP地址,如:

 

 

这样blog.ryanzoe.top就指向了我们所选择的IP。当然,你也可以填写上面的IP。但是既然上面设置别名的话,用CNAME间接指向,解析时间会比A快(即生效时间)

其他服务商的后台管理也有相似的操作区域,如何大家有这种需要的,可以参考博主这篇文章进行相应的设置。

测试二级域名

通过命令去 ping blog.ryanzoe.top,如出现ip地址并且ping成功,表名解析成功。

登录服务器,修改nginx配置文件

vim /data/server/nginx/conf/nginx.conf

 

server {
listen 80; #监听的端口
server_name blog.ryanzoe.top; #监听的域名
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://101.200.172.108:9090; #跳转的url和接口
}
access_log logs/blog_access.log; 
}

 

保存配置文件,重启nginx:

systemctl restart nginx

 

5,测试:浏览器地址栏输入:blog.ryanzoe.top

Guess you like

Origin www.cnblogs.com/ryanzheng/p/11280172.html