1.配置HOSTS
192.168.71.129 www.taobao.com
192.168.71.129 www.sina.com
2.配置nginx配置文件
upstream tomcat_taobao {
server 192.168.71.129:8081; #访问的tomcat的IP
}
server {
listen 80; #监听的对外端口
server_name www.taobao.com; #域名
location / {
proxy_pass http://tomcat_taobao; #必须与服务器上对应的tomcat的upstream tomcat_taobao相对应
index index.html index.htm;
}
}
upstream tomcat_sina {
server 192.168.71.129:8082; #访问的tomcat的IP
}
server {
listen 80;#监听的对外端口
server_name www.sina.com;#域名
location / {
proxy_pass http://tomcat_sina; #必须与服务器上对应的tomcat的upstream tomcat_sina相对应
index index.html index.htm;
}
}