一个ip可以对应多个域名,比如现有:www.abc.com,需要增加test.abc.com
先在域名解析中,添加A记录,主机记录为test,记录值和www的记录值一样
服务器中80端口设置为nginx,nginx.conf配置如下:
server {
listen 80;
server_name www.abc.com;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
upstream myServer {
server 59.110.40.41:8080;
server 59.110.40.41:8090;
}
server {
listen 80;
server_name test.abc.com;
location / {
proxy_pass http://myServer;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
myServer为负载均衡配置