首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Jhipster网关中代理请求?

如何在Jhipster网关中代理请求?
EN

Stack Overflow用户
提问于 2019-01-05 15:23:34
回答 1查看 721关注 0票数 1

我使用jhipster-gateway创建了一对微型服务和一个https://start.jhipster.tech/#/

在网关中,来自微服务的所有API都是可用的,但我需要在请求前缀中传递微服务名称。例如

代码语言:javascript
复制
http://localhost:8080/user-service/api/user
http://localhost:8080/pet-service/api/pets

为此,我希望将其配置为不需要将服务名称传递到路径url中,如下所示

代码语言:javascript
复制
http://localhost:8080/api/user
http://localhost:8080/api/pets

我尝试用zuul配置来修复它,如下所示

代码语言:javascript
复制
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

我从创始成员那里跟踪了这个演示。UW7pw

PS:我是新来的杰普斯特,并为我的下一个项目评估它。任何帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

发布于 2019-01-18 21:31:54

我认为您应该在zuul中设置前缀并设置路径映射。如下所示:

代码语言:javascript
复制
zuul.prefix=/api //define a path for the gateway
zuul.ignored-services=* //ignore services that mustn't exposed
zuul.routes.userService.path=/users/** //map of service
zuul.routes.userService.serviceId=user-service
zuul.routes.userService.path=/pets/**
zuul.routes.petService.serviceId=pet-service

把我的答案写在属性上而不是yaml里。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54053386

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档