I am configuring spring Boot actuator but the /actuator and /health endpoints return a 405 in each GET request.
I opened up the entire security mechanism but it's not working:
management.endpoints.jmx.exposure.exclude=*
management.endpoints.web.exposure.include=health,info,beans,env
management.endpoint.health.enabled=true
management.security.enabled=false
management.endpoint.beans.cache.time-to-live=10s
management.endpoints.web.cors.allowed-origins=*
management.endpoints.web.cors.allowed-methods=GET,POST
I added the following config
@Configuration(proxyBeanMethods = false)
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/health", "/actuator").permitAll().and().csrf().disable();
super.configure(http);
}
}
So, I followed the tutorial and it seems pretty simple, I don't see why I get this 405 on the default GET request. When I call the endpoint with cURL:
curl http://localhost:8080/sm-integration/health -v --> 405
curl -X POST http://localhost:8080/sm-integration/health -v --> 400
I don't understand the 400 Bad Request when doing a POST. The docs state that /health is the most basic and open endpoint and should be called as a GET call. So why the 405?
update After receiving several answers, I have set the config like this:
@Override
public void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/health", "/actuator/**").permitAll().and().csrf().disable();
}
I changed the call to http://localhost:8080/sm-integration/actuator/health
But I still get the 405.
In the Tomcat access logging I do see the request has arrived.
10.0.2.2 - - [06/Jul/2020:16:41:06 +0000] "GET /sm-integration/actuator/health HTTP/1.1" 405 5
10.0.2.2 - - [06/Jul/2020:16:41:12 +0000] "GET /sm-integration/actuator/health HTTP/1.1" 405 5
10.0.2.2 - - [06/Jul/2020:16:41:45 +0000] "GET /sm-integration/actuator/health HTTP/1.1" 405 5
10.0.2.2 - - [06/Jul/2020:16:42:18 +0000] "GET /sm-integration/actuator/health HTTP/1.1" 405 5
10.0.2.2 - - [06/Jul/2020:16:43:04 +0000] "GET /sm-integration/actuator HTTP/1.1" 405 5
/
,/health
is the wrong path. It should be/actuator/health
. – Andy Wilkinson