【发布时间】:2019-05-31 21:04:36
【问题描述】:
我使用https://start.jhipster.tech/#/
创建了几个微服务和一个jhipster-gateway在网关中,来自微服务的所有 API 都可用,但我需要在请求前缀中传递微服务名称。例如
http://localhost:8080/user-service/api/user
http://localhost:8080/pet-service/api/pets
代替这个,我想配置它,这样我就不需要在路径 url 中传递服务名称,如下所示
http://localhost:8080/api/user
http://localhost:8080/api/pets
我已尝试使用zuul 配置修复它,如下所示
zuul:
sensitive-headers: Cookie,Set-Cookie
host:
max-total-connections: 1000
max-per-route-connections: 100
semaphore:
max-semaphores: 500
routes:
pets:
path: /api/pets/**
serviceId: pet-service
stripPrefix: true
users:
path: /api/user/**
serviceId: user-service
stripPrefix: true
我从创始成员那里关注了这个演示。 https://www.youtube.com/watch?v=FuG5t_UW7pw
PS:我是 Jhipster 的新手,正在为我的下一个项目评估它。非常感谢任何帮助。
【问题讨论】:
-
这并不像在yaml中配置路由那么简单,您需要修改代码以支持swagger url重写,访问控制过滤器,路由定位器等。代码不是很复杂但您需要以某种方式配置它。顺便说一句,你的标题是错误的,它是关于代理请求而不是重定向它们。
-
视频长2h41m,非常感谢! (我喜欢带有法语(任何类型)口音xD的英语)看到/找到了这个(搜索'jhispter + zuul'):jhipster.tech/traefik? (但抱歉,不适合回答/您的 50 代表。))
标签: java spring jhipster netflix-zuul