【问题标题】:SpringBootAdmin doesn't works properly with SpringBootGatewaySpring Boot Admin 无法与 Spring Boot Gateway 一起正常工作
【发布时间】:2019-04-26 09:49:28
【问题描述】:

我在 Eureka 服务器中注册了 SpringBootAdmin 应用程序。另外,我正在使用 SpringBootGateway 服务器来启动我所有的微服务。

接下来是我的管理服务器配置:

cloud:
  gateway:
    discovery:
      locator:
        enabled: true
        lower-case-service-id: true

server:
port: 50100

eureka:
client:
  serviceUrl:
    defaultZone: http://localhost:8761/eureka
instance:
  preferIpAddress: true

所以我可以按名称获取所有服务器。我称我的管理服务器为“admin” - spring.application.name=admin

当我尝试在 Spring 管理服务器上设置网关服务器时,我看到 Spring-admin 服务器尝试从 http://{gateway:port}/xxxxxx.js 获取前端文件,而不是 http://{gateway:port} /admin/xxxxxx.js,所以我看到了一个白页。

我找到了相同的issue。似乎已经解决了。但我认为没有。我使用'de.codecentric:spring-boot-admin-starter-server:2.1.4'。我的后端控制器工作正常 - 我可以在 http://{gateway:port}/admin/test 上发出请求并获得预期的响应。 如何修复或配置 Spring Boot 管理前端文件的路由? 谢谢。

【问题讨论】:

    标签: routing url-routing api-gateway spring-boot-admin


    【解决方案1】:

    您需要将您的管理服务器设置为使用网关,因为它是公共 URL,如下配置:

    spring:
      boot:
        admin:
          ui:
            public-url: "http://{gateway:port}/admin/"
    

    https://codecentric.github.io/spring-boot-admin/current/#_running_behind_a_front_end_proxy_server

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-04
      • 2017-09-21
      • 2021-11-02
      • 2020-02-09
      • 2019-01-23
      • 2021-11-10
      • 2018-09-23
      • 2015-04-20
      相关资源
      最近更新 更多