Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

26.2. 与 Spring Boot Actuator 有关的配置

application.properties

跨域配置

		
management.endpoints.web.cors.allowed-origins=https://example.com
management.endpoints.web.cors.allowed-methods=GET,POST		
		
		

26.2.1. 禁用HTTP端点

如果您不想通过HTTP公开端点,则可以将管理端口设置为-1,如以下示例所示:

			
management.server.port=-1			
			
			

26.2.2. 安全配置

			
security.basic.enabled=true
security.basic.path=/admin    #针对/admin路径进行认证
security.user.name=admin     #认证使用的用户名
security.user.password=password   #认证使用的密码
management.security.roles=SUPERUSER

management.port=11111   #actuator暴露接口使用的端口,为了和api接口使用的端口进行分离
management.context-path=/admin   #actuator暴露接口的前缀
management.security.enabled=true   #actuator是否需要安全保证

endpoints.metrics.sensitive=false   #actuator的metrics接口是否需要安全保证
endpoints.metrics.enabled=true

endpoints.health.sensitive=false  #actuator的health接口是否需要安全保证
endpoints.health.enabled=true			
			
			

26.2.3. 修改 actuator 地址

		
management:
  endpoints:
    web:
      base-path: /monitor		
		
			

26.2.4. 关机

配置文件中加入

		
management.endpoint.shutdown.enabled=true		
		
			
		
curl -X POST www.netkiller.cn:8080/actuator/shutdown