After adding secure authentication of eureka registry server, the new version springcloud there is a problem that is registered to the service center Times in client a mistake: Can not execute request on any known server, again carefully looked at the official document Securing The Eureka Server part is resolved.
Add security authentication: https://www.cnblogs.com/zrk3/p/springcloud_securing_eurekaserver.html
First, official documents
The effect (English is not good, forgive me):
Simply Spring -boot-starter- security will be added to the service path Spring Security, you can protect the Eureka service. By default, when Spring Security on the classpath it will require a valid CSRF sends a token every time the transmission request to the application. Eureka client does not usually have a valid token cross-site request forgery (CSRF), you need to disable this request / Eureka / ** endpoints
2. Add a profile
Add a profile in eureka service project:
package com.zrk.config; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; /** * @Description: * @Author: zrk * @Date: 2019/9/12 */ @EnableWebSecurity class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().ignoringAntMatchers("/eureka/**"); super.configure(http); } }
Restart eureka service, restart the client discovered already registered successfully.