使用nginx可以实现不同的dns指向同一个ip之后、通过server进行分发到不同的ip跟端口、也可以实现301、302等的重定向。
weibo.buxiasen.com
blog.buxiasen.com
类似这种效果、
因为域名没有备案、貌似在阿里云没办法加301跟nginx。。。
所以选择了使用亚马逊的临时服务器作为nginx中转 好绕。。
sudo apt-get install nginx 之后
在/etc/nginx/site-enabled 文件夹内加入以下一段文本、文件名任意
server{
server_name blog.buxiasen.com www.buxiasen.com;
location / {
proxy_pass http://jaonbu.github.io;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
就实现了blog地址的重映射
放入以下文本就可以实现301
实现weibo的301重定向
server{
server_name weibo.buxiasen.com
location / {
return 301 http://weibo.com/buxiasen;
}
}
然后把对应的dns解析到nginx服务器 就可以了
后续补充