谷粒商城踩坑汇总(分布式高级篇)
二、分布式高级篇
P140:配置网关和nginx后,虚拟机访问不到商城首页
1.如果nginx里写这个ip:
upstream gulimall { server 192.168.56.1:88; }
页面转半天,最后出来一个404
2.如果写这个ip:
upstream gulimall { server 192.168.1.28:88; }
就立马报:
Whitelabel Error PageThis application has no configured error view, so you are seeing this as a fallback.Sun Sep 27 12:05:36 CST 2020
There was an unexpected error (type=Not Found, status=404).
最后发现,这里有两个问题:
-
必须使用server 192.168.1.28:88; 这个IP才行,否则连 http://gulimall.com/api/product/attrattrgrouprelation/list 都不能访问
-
还要注意在后台的网关项目里,路由规则不能按雷神写的:
- id: gulimall_host_route uri: lb://gulimall-product predicates: - Host=**.gulimall.com,gulimall.com
如果写成这样,/api/接口能访问,但首页访问不到
必须把**.gulimall.com写在后面,或者去掉,例如:
- Host=gulimall.com,**.gulimall.com