如何使用netflix zuul转发到不同的路径?

问题描述 投票:1回答:1

我正在使用嵌入在spring boot 1.5.x应用程序中的netflix zuul。 zuul背后是一些微服务。这些微服务公开/ public / **下的公共端点。

现在我想通过zuul api网关公开这些公共端点,但从最终的api网关URL中删除“/ public”。

来自外部的示例(预期)(通过zuul api网关请求):

api.yourdomain.tld/path/to/service/endpoint

Zuul应该将此请求转发给(在/ url中的/ public):

service:{port}/public/path/to/service/endpoint

如何在不使用zuul配置中的url参数的情况下实现此目的。我想依靠使用serviceId参数的内部客户端负载平衡。我无法理解。

如果这不是一个好的模式,我应该将我的微服务分成web服务和核心服务吗?那么只有通过Zuul安装/访问web服务?

此配置工作正常,但它使用url参数而不是serviceId:

    custom-service:
      path: /path/to/service/endpoint/**
      stripPrefix: false
      url: http://custom-service:51022/public
      sensitiveHeaders:
reverse-proxy http-proxy netflix-zuul spring-cloud-netflix
1个回答
0
投票

您需要通过Spring Cloud Netflix qazxsw poi发现服务,检查qazxsw poi和qazxsw poi

设置完成后,在zuul应用程序中启用zuul代理和发现客户端

Eureka

比:

Introduction

Zuul应用程序不需要在Eureka注册,它应该获取注册表。

而且你可以说:

How to declare routes with serviceId

如果要为一个服务定义多个路由,请执行以下操作:

@EnableZuulProxy
@EnableDiscoveryClient
@SpringBootApplication
public class ZuulProxyApplication {

   public static void main(String[] args) {
       SpringApplication.run(ZuulProxyApplication.class, args);
   }
}
© www.soinside.com 2019 - 2024. All rights reserved.