Spring Cloud - 22. Spring Cloud Config 연동 Actuator 2

목차

Spring Cloud로 개발하는 마이크로서비스 애플리케이션 22 - Spring Cloud Config 연동 Actuator 2

// 외부 Config를 가져오기 위한 Dependency 설정
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap'

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator
implementation 'org.springframework.boot:spring-boot-starter-actuator'
spring:
cloud:
config:
uri: http://127.0.0.1:8888
name: ecommerce
@SpringBootApplication
public class ApigatewayServiceApplication {

public static void main(String[] args) {
SpringApplication.run(ApigatewayServiceApplication.class, args);
}

@Bean
public HttpTraceRepository httpTraceRepository(){
return new InMemoryHttpTraceRepository();
}
}
server:
port: 8080

eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost:8761/eureka

spring:
application:
name: apigateway-service
cloud:
gateway:
default-filters:
- name: GlobalFilter
args:
baseMessage: Spring Cloud Gateway Global Filter
preLogger: true
postLogger: true

routes:
# - id: user-service
# uri: lb://USER-SERVICE
# predicates:
# - Path=/user-service/**
# filters:
# - CustomFilter
- id: user-service
uri: lb://USER-SERVICE
predicates:
- Path=/user-service/login
- Method=POST
filters:
- RemoveRequestHeader=Cookie
- RewritePath=/user-service/(?<segment>.*), /$\{segment}

- id: user-service
uri: lb://USER-SERVICE
predicates:
- Path=/user-service/users
- Method=POST
filters:
- RemoveRequestHeader=Cookie
- RewritePath=/user-service/(?<segment>.*), /$\{segment}

- id: user-service
uri: lb://USER-SERVICE
predicates:
- Path=/user-service/**
- Method=GET
filters:
- RemoveRequestHeader=Cookie
- RewritePath=/user-service/(?<segment>.*), /$\{segment}
- AuthorizationHeaderFilter

- id: user-service
uri: lb://USER-SERVICE
predicates:
- Path=/user-service/actuator/**
- Method=GET, POST
filters:
- RemoveRequestHeader=Cookie
- RewritePath=/user-service/(?<segment>.*), /$\{segment}

- id: catalog-service
uri: lb://CATALOG-SERVICE
predicates:
- Path=/catalog-service/**
filters:
- CustomFilter

- id: order-service
uri: lb://ORDER-SERVICE
predicates:
- Path=/order-service/**
filters:
- CustomFilter

token:
secret: user_token

management:
endpoints:
web:
exposure:
include: refresh, health, beans, httptrace
Share