测试环境 修改host文件
nginx支持三种类型的虚拟主机配置,
1、基于ip的虚拟主机,
2、基于端口的虚拟主机
3、基于域名的虚拟主机
192.168.5.135 www.taotao.com
192.168.5.135 taotao.com
192.168.5.135 rest.taotao.com
192.168.5.135 search.taotao.com
192.168.5.135 sso.taotao.com
192.168.5.135 order.taotao.com
192.168.5.135 manager.taotao.com
nginx中的配置(简化)
http {
include mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name manager.taotao.com;
location / {
proxy_pass http://manager.taotao.com;
index index.html index.htm;
}
}
server {
listen 80;
server_name rest.taotao.com;
location / {
proxy_pass http://rest.taotao.com;
index index.html index.htm;
}
}
server {
listen 80;
server_name search.taotao.com;
location / {
proxy_pass http://search.taotao.com;
index index.html index.htm;
}
}
server {
listen 80;
server_name sso.taotao.com;
location / {
proxy_pass http://sso.taotao.com;
index index.html index.htm;
}
}
server {
listen 80;
server_name order.taotao.com;
location / {
proxy_pass http://order.taotao.com;
index index.html index.htm;
}
}
server {
listen 80;
server_name www.taotao.com;
location / {
proxy_pass http://www.taotao.com;
index index.html index.htm;
}
}
upstream rest.taotao.com{
server 192.168.5.139:8080;
}
upstream search.taotao.com{
server 192.168.5.139:8081;
}
upstream sso.taotao.com{
server 192.168.5.139:8082;
}
upstream order.taotao.com{
server 192.168.5.139:8083;
}
upstream www.taotao.com{
server 192.168.5.138:8080;
}
upstream manager.taotao.com{
server 192.168.5.137:8080;
}
}