SBA 版本 2.0.1
Spring-Cloud Finchley.RELEASE
我在 Eureka 注册了一些服务。这些服务是 Spring-Boot 应用程序,它们的执行器由 HTTP 基本身份验证保护。服务执行器位于 /actuator。这些服务正在运行,我可以通过 Postman 和 curl 与它们的执行器进行交互。SBA 连接到 Eureka 并发现服务,但它们始终处于关闭(红色)状态,除了 SBA 应用程序本身,它在 SBA 控制台中显示为绿色,我可以单击它并查看它的属性。
当我单击其中一个服务实例时,系统会提示我输入凭据。我不确定要使用什么凭据,所以我使用服务执行器的凭据。如文档中所示,我已经在元数据映射中拥有这些凭据,但仍然提示我输入凭据。这总是会导致显示 Whitelabel 错误页面,并显示如下错误消息:
2018 年 6 月 25 日星期一 12:40:57 CDT 出现意外错误(类型=不允许方法,状态=405)。不支持请求方法“POST”
尽管我注意到该错误的 url 显然是在 SBA 实例本身上,而不是在远程服务上。url 解码为:http://localhost:8080/#/instances/9207aa5fc06b/
但是我在服务的日志中看到了这一点,因此显然未经身份验证的请求正在将其发送到删除服务:
[2018-06-25 12:16:54.242] - 调试 - [http-nio-8380-exec-7] [AUTHENTICATION_SERVICE_DEV,8dc8165d4f77be7c,8dc8165d4f77be7c,false] --- [nio-8380-exec-7] oswsmmaHttpEntityMethodProcessor:已编写[{timestamp=Mon Jun 25 12:16:54 CDT 2018, status=401, error=Unauthorized, message=Unauthorized, path=/actuator/health}] as "application/vnd.spring-boot.actuator.v2+json " 使用 [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@30c8681]
这在 SBA 日志中:
2018-06-25 12:39:40.884 错误 [SERVICES_ADMIN_CONSOLE_LOCAL,,,] 20728 --- [nio-8080-exec-8] oaccC[.[.[/].[dispatcherServlet]: Servlet.service() 用于 servlet [dispatcherServlet] 在路径 [] 的上下文中抛出异常
java.io.IOException:已建立的连接被主机中的软件中止
这是我困惑的根源,我不确定我需要什么凭据,甚至我正在验证什么。我已经在属性和登录表单中提供了远程服务的凭据,但它不起作用。
当我在 SBA 控制台中单击 SBA 应用程序时,它按预期工作。所以这似乎与对远程执行器的身份验证有关,但我无法弄清楚问题是什么。
服务器:
@Configuration
@EnableAutoConfiguration
@EnableEurekaClient
@EnableAdminServer
public class ServiceAdmin {
public static void main(String[] args) {
SpringApplication.run(ServiceAdmin.class, args);
}
@Configuration
public static class SecurityPermitAllConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().permitAll()
.and().csrf().disable();
}
}
}
SBA 配置:
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
management.info.git.mode=full
management.endpoint.shutdown.enabled=true
spring.security.user.name=actuator
spring.security.user.password=password
spring.security.user.roles=ACTUATOR
eureka.instance.leaseRenewalIntervalInSeconds=10
eureka.instance.health-check-url-path=/actuator/health
eureka.instance.metadata-map.user.name=actuator
eureka.instance.metadata-map.user.password=password
eureka.client.registryFetchIntervalSeconds=5
eureka.client.serviceUrl.defaultZone=http://svcregistry1.mycompany.com/eureka/,http://svcregistry2.mycompany.com