gateway context-path不生效问题
来源:7-14 验证网关微服务功能可用性

就叫香菜算了
2021-07-31
如题,本来想测试gateway可用性,启动了所有的服务,发现gateway模块在admin中显示down,最后发现是启动的时候,context-path不生效.
http://127.0.0.1/gateway/actuator 404
http://127.0.0.1/actuator 就能访问到
难道就我一个人碰见了这个问题?大家都没问题?
查了一下资料有些人说是新增一个router让自己访问自己…
但是想请教一下老师有没有更好的解决方法
写回答
4回答
-
就叫香菜算了
提问者
2021-08-01
问题已解决 如图
112021-08-01 -
燎丶Trance
2021-09-15
解决方案:
@Bean public WebFilter contextPathWebFilter(ServerProperties serverProperties) { String contextPath = serverProperties.getServlet().getContextPath(); return (exchange, chain) -> { ServerHttpRequest request = exchange.getRequest(); if (request.getURI().getPath().startsWith(contextPath)) { return chain.filter( exchange.mutate() .request(request.mutate().contextPath(contextPath).build()) .build()); } return chain.filter(exchange); }; }
在请求的时候, 添加上去
00 -
就叫香菜算了
提问者
2021-07-31
另外附上一张gateway启动截图以及能被admin监控到的服务截图(拜谢)
012021-07-31 -
就叫香菜算了
提问者
2021-07-31
其实主要想解决的是想把gateway和admin整合成功,代码直接复制的还是不行,感觉是不是因为就是因为前面没有项目名称,所以admin就没有监控到
00
相似问题