SpringBootAdmin

spring-boot-admin-server

어드민 서버

그래들

1
2
3
4
5
implementation("org.springframework.boot:spring-boot-starter-security:2.5.6")
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web
implementation("org.springframework.boot:spring-boot-starter-web:2.5.6")
// https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-starter-server
implementation("de.codecentric:spring-boot-admin-starter-server:2.5.4")

메인 메서드

  • 어노테이션 추가
1
@EnableAdminServer

시큐리티 설정

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

@Configuration
class SecurityConfig : WebSecurityConfigurerAdapter() {

    var adminServerProperties = AdminServerProperties();

    override fun configure(http: HttpSecurity?) {
        val contextPath = this.adminServerProperties.contextPath

        val successHandler = SavedRequestAwareAuthenticationSuccessHandler()
        successHandler.setTargetUrlParameter("redirectTo")
        successHandler.setDefaultTargetUrl("/")

        http!!.authorizeRequests()
            .antMatchers("$contextPath/assets/**").permitAll()
            .antMatchers("$contextPath/login").permitAll()
            .antMatchers(HttpMethod.GET, "/actuator/**").permitAll()
            .anyRequest().authenticated()
            .and()
            .formLogin().loginPage("$contextPath/login").successHandler(successHandler)
            .and()
            .logout().logoutUrl("$contextPath/logout")
            .and()
            .httpBasic()
            .and()
            .csrf()
            .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
            .ignoringAntMatchers(
                "$contextPath/instances",
                "$contextPath/actuator/**"
            )
    }
}

yml

1
2
3
4
5
6
7
8
9
10
11
server:
  port: 50000
spring:
  security:
    user:
      name: admin
      password: admin
#boot:
  #  admin:
  #   ui:
  #     public-url: https://gorani.wecruitpro.com:443/  # 프록시 사용하는 경우

관리하는 프로젝트

yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
management:
  endpoints:
    web:
      exposure:
        include: '*'
  endpoint:
    health:
      show-details: always
spring:
  boot:
    admin:
      client:
        auto-registration: 'true'
        password: admin
        url: http://localhost:50000 # admin url
        username: admin

그래들

1
2
3
4
// https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-starter-client
implementation 'de.codecentric:spring-boot-admin-starter-client:2.5.4'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'

SpringBootAdmin