繁体   English   中英

Spring Boot Back-End with Angular Front-End 从普罗米修斯和健康端点获取状态和指标,但 401

[英]Spring Boot Back-End with Angular Front-End getting status and metrics from prometheus and health endpoint but 401

在集群上部署时遇到 401 错误问题。 请注意在本地开发期间未发生的问题。 只有在测试集群上部署后才会出现问题。 目前该项目仅处于开发/测试阶段。

后端配置(Spring 属性文件):

 server.port=8085 management.health.defaults.enabled=false management.endpoint.health.show-details="ALWAYS" management.server.port=${management.port:1234} management.endpoints.enabled-by-default=true management.endpoints.web.base-path=/ management.endpoints.web.exposure.include=health, prometheus

Angular:登录成功(使用相对 url 到端口 8085 一旦部署在集群上)但登录后我的仪表板页面调用执行器健康和普罗米修斯端点:

这些是 URL: healthUrl: "http://localhost:1234/health" metricsUrl: "http://localhost:1234/prometheus"

弹簧安全:

 @Configuration @EnableWebSecurity public class ActuatorWebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http .csrf().disable() .cors().configurationSource(corsConfigurationSource()) .and() .authorizeRequests() .requestMatchers(EndpointRequest.to(HealthEndpoint.class, InfoEndpoint.class)).permitAll() .antMatchers("/**").authenticated() .and().httpBasic() .and() .addFilterBefore(new ForwardedHeaderFilter(), UsernamePasswordAuthenticationFilter.class); } @Bean CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); configuration.setAllowedOrigins(Arrays.asList("*")); configuration.setAllowCredentials(true); configuration.setAllowedMethods(Arrays.asList("GET","POST","OPTIONS")); configuration.setAllowedHeaders(Collections.singletonList("*")); UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.registerCorsConfiguration("/**", configuration); return source; } }

请为整个类提供安全配置,包括所有注释,以便我们更好地理解它。

以下是一些深入研究的建议

  1. 假设您的普罗米修斯本身通过 HTTPS 提供服务,您可以发布您的 tls 配置吗? 我怀疑这有一些问题,你也可以在 prometheus 文件中重新检查你的 spring-actuator 配置。
  2. 你能检查普罗米修斯文件中的指标、健康、信息路径吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM