Normally the /health endpoint is exposed automatically. Despite that, I do already have management.endpoints.web.exposure.include=health,metrics
in my application.properties file, but every time I try to access it, it redirects back to /login. What am I missing?
I updated my SecurityConfig.
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(
authorize -> authorize.requestMatchers(new AntPathRequestMatcher("/images/*.png")).permitAll());
// Icons from the line-awesome addon
http.authorizeHttpRequests(authorize -> authorize
.requestMatchers(new AntPathRequestMatcher("/line-awesome/**/*.svg")).permitAll());
http.authorizeHttpRequests(authorize -> authorize
.requestMatchers(new AntPathRequestMatcher("/actuator/health")).permitAll());
super.configure(http);
setLoginView(http, LoginView.class);
}
Spring has a helper class for it.
http.securityMatcher(EndpointRequest.toAnyEndpoint());
Note: I would recommend to change the port of the actuator (management.server.port)
1 Like
Thanks Christian. Is that for security reasons?
How would I access it, then, if my service is setup to expose port 8080? I guess I don’t really understand how any port besides the one set by server.port=${PORT:8080}
can be accessible.
Oh, I think I got it: http://localhost:9090/actuator/health for example
Unfortunately, in Railway, it doesn’t seem like there’s a way to set the Health endpoint different than the application.