如何使用Spring Cloud Gateway&丝带
我有2个与HTTP一起使用的微服务,我添加了Spring Cloud Gateway API以集中路线,但我遇到了一个问题:主机和端口的组合需要TLS
我很确定这是因为这是因为我网关上的路线配置,我在这方面没有太多经验,但是如果有人可以帮助我。
这是我的Spring Gateway路线配置:
@Bean
public RouteLocator gatewayRouter(RouteLocatorBuilder builder){
return builder.routes()
.route(p -> p.path("/api/v1/**")
.uri("lb://statement"))
.route( p -> p.path("/api/v3/**")
.uri("lb://activiti-workflow"))
.build();
}
请我只想知道此配置是否会重定向到HTTPS,因为当直接将HTTP请求直接发送到其有效的微服务时,但与Gateway并非如此。
I have 2 microservices working with https, I added spring cloud gateway api to centralize the routes but I faced a problem where it says: This combination of host and port requires TLS
I'm pretty sure that's because of the routes configuration on my gateway, I dont have much experience on this side but if someone could help me.
this is my spring gateway routes configuration :
@Bean
public RouteLocator gatewayRouter(RouteLocatorBuilder builder){
return builder.routes()
.route(p -> p.path("/api/v1/**")
.uri("lb://statement"))
.route( p -> p.path("/api/v3/**")
.uri("lb://activiti-workflow"))
.build();
}
Please I just want to know if this configuration will redirects to https or not, because while sending http requests directly to the microservices it works but with gateway is doesn't.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在尤里卡(Eureka)的后端服务提供HTTPS,则可以像这样设置路由URI:
或者
像WebSocket配置一样。密钥类是
org.springframework.cloud.gateway.filter.routetetorequesturlfilter
更多信息,请参见: https://cloud.spring.io/spring-cloud-cloud-gateway/reference/reference/html/#the-routetetorequesturl-filter
使用不安全的https cert,您可能需要的配置以下内容:
请参阅: https://cloud.spring.io/spring-cloud-gateway/reference/html/#tls-and-s-ssl
If your backend services in eureka provide https, your can set route uri like this:
Or
It just like websocket configuration. The key class is
org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter
More info see at: https://cloud.spring.io/spring-cloud-gateway/reference/html/#the-routetorequesturl-filter
If your backend services use insecure HTTPS cert, your may need config this:
See at: https://cloud.spring.io/spring-cloud-gateway/reference/html/#tls-and-ssl