修改:C:\Windows\System32\drivers\etc\hosts
# 文件末尾添加(需保证192.168.56.10已搭建好nginx环境)
192.168.56.10 gulimall.com
修改nginx配置文件中server模块server_name的值为gulimall.com
server_name gulimall.com;
负载均衡到网关
# http模块下添加(每个server对应一台服务器):
upstream gulimall {
server 192.168.56.1:88;
server 192.168.56.2:88;
}
# 修改:
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
# 为:
location / {
# nginx代理给网关时,会丢失请求的host信息,所以添加proxy_set_header
proxy_set_header Host $host;
proxy_pass http://gulimall;
}
- id: gulimall_host_route
uri: lb://gulimall-product
predicates:
- Host=**.gulimall.com