谷粒商城踩坑汇总(分布式高级篇)

二、分布式高级篇
 
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 Page
This 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).
 
最后发现,这里有两个问题:
  1. 必须使用server 192.168.1.28:88; 这个IP才行,否则连 http://gulimall.com/api/product/attrattrgrouprelation/list 都不能访问
  2. 还要注意在后台的网关项目里,路由规则不能按雷神写的:
    - id: gulimall_host_route
      uri: lb://gulimall-product
      predicates:
       - Host=**.gulimall.com,gulimall.com

   如果写成这样,/api/接口能访问,但首页访问不到

 
   必须把**.gulimall.com写在后面,或者去掉,例如:
       - Host=gulimall.com,**.gulimall.com
 
 
 
posted @ 2020-09-27 17:16  大厨无盐煮  阅读(2439)  评论(0编辑  收藏  举报