简体   繁体   中英

Spring boot actuator health check context path

My Spring boot server context-path : /test

I have authentication setup for the " https://localhost:8443/test " base path using nginx configuration and the rest api's within this base path are edge services.

Problem: I don't want my health service to be exposed as an edge service and undergo authentication. But actuator's health check comes as admin service and the admin's context-path is not overriding the application's base path.

Is there any tweak which I can do in my application to differentiate context path between rest api's and actuator's health check api's.

Dropwizard does this pretty easily.

You can use spring-security to secure the management endpoints:

Add spring-boot-starter-security to your dependencies:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>

This by itself will secure all endpoints. If you want only the mgmt ones secured, add this property:

security.basic.enabled=false

You can also set a different user/password for that:

security.user.name=admin
security.user.password=new_password

Credit to this post

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM