【问题标题】:Camunda behind Spring Cloud Gateway not returning CSS files for cockpitSpring Cloud Gateway 后面的 Camunda 没有返回驾驶舱的 CSS 文件
【发布时间】:2021-01-11 23:41:50
【问题描述】:

我在 Spring Boot 应用程序(称为服务工作流)中嵌入了一个 Camunda 实例,该应用程序在动态端口上启动,通过 Eureka 向 Spring Cloud 注册。

Camunda 服务的主要类很简单:

@EnableDiscoveryClient
@SpringBootApplication
@EnableConfigurationProperties(ServiceContextConfig.class)
public class WorkflowServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(WorkflowServiceApplication.class, args);
    }
}

以及配置属性:

server.port=0
eureka.client.healthcheck.enabled=true

服务位于运行在端口上的本地 Spring Cloud Gateway 后面,该端口使用 Eureka 注册主机 - 并且可以通过 http://localhost:8080 访问和路由

网关的代码是:

@SpringBootApplication
@EnableDiscoveryClient
public class GatewayServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(GatewayServiceApplication.class, args);
    }
}

以及配置属性:

server.port=8080
spring.cloud.gateway.discovery.locator.enabled=true
spring.cloud.gateway.discovery.locator.lowerCaseServiceId=true

没有定义路由 - 它完全依赖 Eureka 来查找路由。这对 REST 连接没有问题。

任何使用 runtimeService 的客户端,都可以使用带有 URL 的 feign 启动工作流: feign.client.config.remoteRuntimeService.url=service-workflow/rest/

因此,可以通过 REST API 的网关 URL 访问工作流服务。

当 Camunda 服务启动并分配端口 x 时,我可以通过 http://localhost:x/app/cockpit/default/ 查看驾驶舱 但是,如果我尝试通过网关,即 http://localhost:8080/service-workflow/app/cockpit/default/ 它无法返回任何 CSS 文件 - 网关日志显示:

2020-09-25 16:46:00,454 DEBUG [reactor-http-nio-2] reactor.netty.http.server.HttpServer (Loggers.java:254) - [id: 0xe08516d1, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:61018] Handler is being applied: org.springframework.http.server.reactive.ReactorHttpHandlerAdapter@74cedfb5
2020-09-25 16:46:00,453 DEBUG [reactor-http-nio-8] org.springframework.web.server.adapter.HttpWebHandlerAdapter (LogFormatUtils.java:91) - [9407161c-27] HTTP GET "/app/cockpit/styles/styles.css?bust=7.12.0"
2020-09-25 16:46:00,456 DEBUG [reactor-http-nio-2] org.springframework.web.server.adapter.HttpWebHandlerAdapter (LogFormatUtils.java:91) - [e08516d1-28] HTTP GET "/app/cockpit/styles/user-styles.css?bust=7.12.0"
2020-09-25 16:46:00,455 DEBUG [reactor-http-nio-7] reactor.netty.http.server.HttpServer (Loggers.java:254) - [id: 0x125a09dc, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:61253] Handler is being applied: org.springframework.http.server.reactive.ReactorHttpHandlerAdapter@74cedfb5
2020-09-25 16:46:00,458 DEBUG [reactor-http-nio-8] org.springframework.web.reactive.handler.SimpleUrlHandlerMapping (AbstractHandlerMapping.java:183) - [9407161c-27] Mapped to ResourceWebHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"]
2020-09-25 16:46:00,460 DEBUG [reactor-http-nio-7] org.springframework.web.server.adapter.HttpWebHandlerAdapter (LogFormatUtils.java:91) - [125a09dc-29] HTTP GET "/app/cockpit/styles/styles-components.css?bust=7.12.0"
2020-09-25 16:46:00,460 DEBUG [reactor-http-nio-2] org.springframework.web.reactive.handler.SimpleUrlHandlerMapping (AbstractHandlerMapping.java:183) - [e08516d1-28] Mapped to ResourceWebHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"]
2020-09-25 16:46:00,463 DEBUG [reactor-http-nio-8] org.springframework.web.reactive.resource.ResourceWebHandler (ResourceWebHandler.java:324) - [9407161c-27] Resource not found
2020-09-25 16:46:00,464 DEBUG [reactor-http-nio-7] org.springframework.web.reactive.handler.SimpleUrlHandlerMapping (AbstractHandlerMapping.java:183) - [125a09dc-29] Mapped to ResourceWebHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"]
2020-09-25 16:46:00,465 DEBUG [reactor-http-nio-2] org.springframework.web.reactive.resource.ResourceWebHandler (ResourceWebHandler.java:324) - [e08516d1-28] Resource not found
2020-09-25 16:46:00,466 DEBUG [reactor-http-nio-7] org.springframework.web.reactive.resource.ResourceWebHandler (ResourceWebHandler.java:324) - [125a09dc-29] Resource not found
2020-09-25 16:46:00,469 DEBUG [reactor-http-nio-2] org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler (CompositeLog.java:147) - [e08516d1-28] Resolved [ResponseStatusException: 404 NOT_FOUND] for HTTP GET /app/cockpit/styles/user-styles.css
2020-09-25 16:46:00,468 DEBUG [reactor-http-nio-8] org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler (CompositeLog.java:147) - [9407161c-27] Resolved [ResponseStatusException: 404 NOT_FOUND] for HTTP GET /app/cockpit/styles/styles.css
2020-09-25 16:46:00,476 DEBUG [reactor-http-nio-2] org.springframework.core.codec.CharSequenceEncoder (CompositeLog.java:147) - [e08516d1-28] Writing "<html><body><h1>Whitelabel Error Page</h1><p>This application has no configured error view, so you  (truncated)...
2020-09-25 16:46:00,479 DEBUG [reactor-http-nio-7] org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler (CompositeLog.java:147) - [125a09dc-29] Resolved [ResponseStatusException: 404 NOT_FOUND] for HTTP GET /app/cockpit/styles/styles-components.css
2020-09-25 16:46:00,477 DEBUG [reactor-http-nio-8] org.springframework.core.codec.CharSequenceEncoder (CompositeLog.java:147) - [9407161c-27] Writing "<html><body><h1>Whitelabel Error Page</h1><p>This application has no configured error view, so you  (truncated)...
2020-09-25 16:46:00,480 DEBUG [reactor-http-nio-7] org.springframework.core.codec.CharSequenceEncoder (CompositeLog.java:147) - [125a09dc-29] Writing "<html><body><h1>Whitelabel Error Page</h1><p>This application has no configured error view, so you  (truncated)...
2020-09-25 16:46:00,480 DEBUG [reactor-http-nio-2] reactor.netty.http.server.HttpServerOperations (Loggers.java:254) - [id: 0xe08516d1, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:61018] Decreasing pending responses, now 0

【问题讨论】:

    标签: camunda spring-cloud-gateway


    【解决方案1】:

    我最终解决这个问题的方法是在网关中添加自定义路由:

    .route("camunda", r -> r.path("/camunda/**")
            //.filters(f -> f.rewritePath("/report/(?<segment>.*)", "/${segment}"))
            .uri("lb://my-camunda-service"))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-30
      • 2019-04-22
      • 1970-01-01
      • 1970-01-01
      • 2019-03-25
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多