Consul health check pass by Spring security filter

https://stackoverflow.com/questions/35079930/consul-health-check-pass-by-spring-security-filter

By default consul from spring-cloud-starter-consul-discovery use /actuator/health to check health.
When spring-security is used, should provide & permit that path.

Steps:

  • Permit /actuator/health in spring-security, then consul could perform the health check.

    e.g

    httpSecurity.csrf().disable() 
        .authorizeRequests().antMatchers("/hello", "/authenticate", "/actuator/health")
        .permitAll().
    
  • Add actuator dependency, if not yet.

  • Expose endpoints

    e.g

    management:
      endpoints:
        web:
          exposure:
            include: "*"
    
原文地址:https://www.cnblogs.com/exmyth/p/15769425.html