This commit is contained in:
hiondal
2025-09-09 01:12:14 +09:00
parent 7ec8a682c6
commit b489c73201
276 changed files with 43859 additions and 98 deletions
@@ -0,0 +1,128 @@
# API Gateway 개발 환경 설정
server:
port: 8080
spring:
# Cloud Gateway 개발환경 설정
cloud:
gateway:
default-filters: []
globalcors:
cors-configurations:
'[/**]':
allowed-origin-patterns:
- "http://localhost:*"
- "http://127.0.0.1:*"
- "https://localhost:*"
allowed-methods: "*"
allowed-headers: "*"
allow-credentials: true
max-age: 86400 # 24시간
# 개발도구 설정
devtools:
restart:
enabled: true
additional-paths: src/main/java,src/main/resources
livereload:
enabled: true
# JWT 설정 (개발용 - 더 긴 유효시간)
app:
jwt:
secret: ${JWT_SECRET:dev-phonebill-api-gateway-jwt-secret-key-256-bit-minimum-length-for-development}
access-token-validity-in-seconds: 3600 # 1시간 (개발편의성)
refresh-token-validity-in-seconds: 172800 # 48시간 (개발편의성)
# Circuit Breaker 설정 (개발환경 - 더 관대한 설정)
resilience4j:
circuitbreaker:
instances:
auth-service-cb:
failure-rate-threshold: 80 # 개발환경은 더 관대한 임계값
wait-duration-in-open-state: 10s
sliding-window-size: 5
minimum-number-of-calls: 3
bill-service-cb:
failure-rate-threshold: 80
wait-duration-in-open-state: 10s
sliding-window-size: 5
minimum-number-of-calls: 3
product-service-cb:
failure-rate-threshold: 80
wait-duration-in-open-state: 10s
sliding-window-size: 5
minimum-number-of-calls: 3
kos-mock-cb:
failure-rate-threshold: 90
wait-duration-in-open-state: 5s
sliding-window-size: 5
minimum-number-of-calls: 2
# Actuator 설정 (개발환경 - 모든 엔드포인트 노출)
management:
endpoints:
web:
exposure:
include: "*" # 개발환경에서는 모든 엔드포인트 노출
base-path: /actuator
endpoint:
health:
show-details: always # 개발환경에서는 상세 정보 항상 표시
shutdown:
enabled: true # 개발환경에서만 활성화
beans:
enabled: true
env:
enabled: true
configprops:
enabled: true
# 로깅 설정 (개발환경 - 더 상세한 로그)
logging:
level:
com.unicorn.phonebill.gateway: ${LOG_LEVEL_GATEWAY:DEBUG}
org.springframework.cloud.gateway: ${LOG_LEVEL_SPRING_CLOUD_GATEWAY:DEBUG}
org.springframework.data.redis: ${LOG_LEVEL_SPRING_DATA_REDIS:DEBUG}
org.springframework.web.reactive: ${LOG_LEVEL_SPRING_WEB_REACTIVE:DEBUG}
reactor.netty.http.client: ${LOG_LEVEL_REACTOR_NETTY_HTTP_CLIENT:DEBUG}
io.netty.handler.ssl: ${LOG_LEVEL_IO_NETTY_HANDLER_SSL:WARN}
root: ${LOG_LEVEL_ROOT:INFO}
file:
name: ${LOG_FILE:logs/api-gateway.log}
max-size: ${LOG_FILE_MAX_SIZE:100MB}
max-history: ${LOG_FILE_MAX_HISTORY:7}
# OpenAPI 설정 (개발환경)
springdoc:
api-docs:
enabled: true
path: /v3/api-docs
swagger-ui:
enabled: true
path: /swagger-ui.html
try-it-out-enabled: true # 개발환경에서 Try it out 활성화
urls:
- name: Auth Service (Dev)
url: http://localhost:8081/v3/api-docs
- name: Bill Service (Dev)
url: http://localhost:8082/v3/api-docs
- name: Product Service (Dev)
url: http://localhost:8083/v3/api-docs
- name: KOS Mock Service (Dev)
url: http://localhost:8084/v3/api-docs
# CORS 설정 (개발환경 - 더 관대한 설정) - 이미 위에서 설정됨
# 개발환경 특성 설정
debug: false
trace: false
# 애플리케이션 정보 (개발환경)
info:
app:
environment: development
debug-mode: enabled
hot-reload: enabled
@@ -0,0 +1,219 @@
# API Gateway 운영 환경 설정
server:
port: 8080
netty:
connection-timeout: 20s
idle-timeout: 30s
compression:
enabled: true
mime-types: application/json,application/xml,text/html,text/xml,text/plain
http2:
enabled: true
spring:
profiles:
active: prod
# Redis 설정 (운영용) - 현재 사용하지 않음
# data:
# redis:
# host: ${REDIS_HOST:redis-cluster.unicorn.com}
# port: ${REDIS_PORT:6379}
# database: ${REDIS_DATABASE:0}
# password: ${REDIS_PASSWORD}
# timeout: 2000ms
# ssl: true # 운영환경에서는 SSL 사용
# lettuce:
# pool:
# max-active: 20
# max-wait: 2000ms
# max-idle: 10
# min-idle: 5
# cluster:
# refresh:
# adaptive: true
# period: 30s
# Cloud Gateway 운영환경 설정
cloud:
gateway:
default-filters:
# - name: RequestRateLimiter # Redis 사용하지 않으므로 주석처리
# args:
# redis-rate-limiter.replenishRate: 500 # 운영환경 적정 한도
# redis-rate-limiter.burstCapacity: 1000
# key-resolver: "#{@userKeyResolver}"
- name: RequestSize
args:
maxSize: 5MB # 요청 크기 제한
globalcors:
cors-configurations:
'[/**]':
allowed-origins:
- "https://app.phonebill.com"
- "https://admin.phonebill.com"
- "https://*.unicorn.com"
allowed-methods:
- GET
- POST
- PUT
- DELETE
allowed-headers:
- Authorization
- Content-Type
- X-Requested-With
allow-credentials: true
max-age: 3600
# JWT 설정 (운영용 - 보안 강화)
app:
jwt:
secret: ${JWT_SECRET} # 환경변수에서 주입 (필수)
access-token-validity-in-seconds: 1800 # 30분 (보안 강화)
refresh-token-validity-in-seconds: 86400 # 24시간
# Circuit Breaker 설정 (운영환경 - 엄격한 설정)
resilience4j:
circuitbreaker:
instances:
auth-service-cb:
failure-rate-threshold: 50
slow-call-rate-threshold: 60
slow-call-duration-threshold: 3s
wait-duration-in-open-state: 30s
sliding-window-size: 100
minimum-number-of-calls: 20
permitted-number-of-calls-in-half-open-state: 10
bill-service-cb:
failure-rate-threshold: 50
slow-call-rate-threshold: 60
slow-call-duration-threshold: 5s
wait-duration-in-open-state: 30s
sliding-window-size: 100
minimum-number-of-calls: 20
product-service-cb:
failure-rate-threshold: 50
slow-call-rate-threshold: 60
slow-call-duration-threshold: 5s
wait-duration-in-open-state: 30s
sliding-window-size: 100
minimum-number-of-calls: 20
kos-mock-cb:
failure-rate-threshold: 60
slow-call-rate-threshold: 70
slow-call-duration-threshold: 10s
wait-duration-in-open-state: 60s
sliding-window-size: 50
minimum-number-of-calls: 10
retry:
instances:
default:
max-attempts: 3
wait-duration: 1s
exponential-backoff-multiplier: 2
retry-exceptions:
- java.net.ConnectException
- java.net.SocketTimeoutException
- org.springframework.web.client.ResourceAccessException
# Actuator 설정 (운영환경 - 보안 강화)
management:
endpoints:
web:
exposure:
include: health,info,metrics,prometheus,gateway # 필요한 것만 노출
base-path: /actuator
endpoint:
health:
show-details: never # 운영환경에서는 상세 정보 숨김
show-components: never
gateway:
enabled: true
shutdown:
enabled: false # 운영환경에서는 비활성화
health:
redis:
enabled: true
circuitbreakers:
enabled: true
info:
env:
enabled: false # 환경 정보 숨김
java:
enabled: true
build:
enabled: true
metrics:
export:
prometheus:
enabled: true
# 로깅 설정 (운영환경 - 성능 고려)
logging:
level:
com.unicorn.phonebill.gateway: INFO
org.springframework.cloud.gateway: WARN
reactor.netty: WARN
io.netty: WARN
root: WARN
file:
name: /var/log/api-gateway/api-gateway.log
max-size: 500MB
max-history: 30
pattern:
file: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%X{traceId:-},%X{spanId:-}] %logger{36} - %msg%n"
loggers:
org.springframework.security: WARN
org.springframework.web: WARN
# OpenAPI 설정 (운영환경 - 비활성화)
springdoc:
api-docs:
enabled: false # 운영환경에서는 비활성화
swagger-ui:
enabled: false # 운영환경에서는 비활성화
# CORS 설정은 위의 spring.cloud.gateway 섹션에서 설정됨
# 보안 설정
security:
headers:
frame:
deny: true
content-type:
nosniff: true
xss:
protection: true
# JVM 튜닝 (운영환경)
jvm:
heap:
initial: 512m
maximum: 1024m
gc:
algorithm: G1GC
options:
- "-server"
- "-XX:+UseG1GC"
- "-XX:G1HeapRegionSize=16m"
- "-XX:+UseStringDeduplication"
- "-XX:+OptimizeStringConcat"
- "-XX:+UnlockExperimentalVMOptions"
- "-XX:+UseJVMCICompiler"
# 모니터링 및 트레이싱
tracing:
enabled: true
sampling:
probability: 0.1 # 10% 샘플링
zipkin:
base-url: ${ZIPKIN_BASE_URL:http://zipkin.monitoring.unicorn.com:9411}
# 애플리케이션 정보 (운영환경)
info:
app:
environment: production
security-level: high
monitoring: enabled
@@ -0,0 +1,186 @@
# API Gateway 기본 설정
# Spring Boot 3.2 + Spring Cloud Gateway
server:
port: ${SERVER_PORT:8080}
netty:
connection-timeout: ${SERVER_NETTY_CONNECTION_TIMEOUT:30s}
idle-timeout: ${SERVER_NETTY_IDLE_TIMEOUT:60s}
http2:
enabled: ${SERVER_HTTP2_ENABLED:true}
spring:
application:
name: api-gateway
profiles:
active: dev
# Spring Cloud Gateway 설정
cloud:
gateway:
default-filters:
- name: AddRequestHeader
args:
name: X-Gateway-Request
value: API-Gateway
- name: AddResponseHeader
args:
name: X-Gateway-Response
value: API-Gateway
# Global CORS 설정
globalcors:
cors-configurations:
'[/**]':
allowed-origin-patterns: "*"
allowed-methods:
- GET
- POST
- PUT
- DELETE
- OPTIONS
- HEAD
allowed-headers: "*"
allow-credentials: true
max-age: 3600
# Discovery 설정 비활성화 (직접 라우팅 사용)
discovery:
locator:
enabled: false
# JSON 설정
jackson:
default-property-inclusion: non_null
serialization:
write-dates-as-timestamps: false
deserialization:
fail-on-unknown-properties: false
# JWT 설정
app:
jwt:
secret: ${JWT_SECRET:phonebill-api-gateway-jwt-secret-key-256-bit-minimum-length-required}
access-token-validity-in-seconds: 1800 # 30분
refresh-token-validity-in-seconds: 86400 # 24시간
# 서비스 URL 설정
services:
auth-service:
url: ${AUTH_SERVICE_URL:http://localhost:8081}
bill-service:
url: ${BILL_SERVICE_URL:http://localhost:8082}
product-service:
url: ${PRODUCT_SERVICE_URL:http://localhost:8083}
kos-mock-service:
url: ${KOS_MOCK_SERVICE_URL:http://localhost:8084}
# Circuit Breaker 설정
resilience4j:
circuitbreaker:
instances:
auth-service-cb:
failure-rate-threshold: 50
wait-duration-in-open-state: 30s
sliding-window-size: 10
minimum-number-of-calls: 5
permitted-number-of-calls-in-half-open-state: 3
bill-service-cb:
failure-rate-threshold: 60
wait-duration-in-open-state: 30s
sliding-window-size: 20
minimum-number-of-calls: 10
product-service-cb:
failure-rate-threshold: 60
wait-duration-in-open-state: 30s
sliding-window-size: 20
minimum-number-of-calls: 10
kos-mock-cb:
failure-rate-threshold: 70
wait-duration-in-open-state: 10s
sliding-window-size: 10
minimum-number-of-calls: 5
retry:
instances:
default:
max-attempts: 3
wait-duration: 2s
exponential-backoff-multiplier: 2
retry-exceptions:
- java.net.ConnectException
- java.net.SocketTimeoutException
- org.springframework.web.client.ResourceAccessException
# Actuator 설정
management:
endpoints:
web:
exposure:
include: health,info,metrics,gateway
base-path: /actuator
endpoint:
health:
show-details: when-authorized
show-components: always
gateway:
enabled: true
health:
redis:
enabled: true
circuitbreakers:
enabled: true
info:
env:
enabled: true
java:
enabled: true
build:
enabled: true
# 로깅 설정
logging:
level:
com.unicorn.phonebill.gateway: ${LOG_LEVEL_GATEWAY:INFO}
org.springframework.cloud.gateway: ${LOG_LEVEL_SPRING_CLOUD_GATEWAY:DEBUG}
reactor.netty: ${LOG_LEVEL_REACTOR_NETTY:INFO}
io.netty: ${LOG_LEVEL_IO_NETTY:WARN}
root: ${LOG_LEVEL_ROOT:INFO}
file:
name: ${LOG_FILE:logs/api-gateway.log}
logback:
rollingpolicy:
max-file-size: 10MB
max-history: 7
total-size-cap: 100MB
pattern:
file: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%X{traceId:-},%X{spanId:-}] %logger{36} - %msg%n"
console: "%d{HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan([%X{traceId:-},%X{spanId:-}]) %logger{36} - %msg%n"
# OpenAPI 설정
springdoc:
api-docs:
enabled: true
path: /v3/api-docs
swagger-ui:
enabled: true
path: /swagger-ui.html
urls:
- name: Auth Service
url: /v3/api-docs/auth
- name: Bill Service
url: /v3/api-docs/bills
- name: Product Service
url: /v3/api-docs/products
# 애플리케이션 정보
info:
app:
name: PhoneBill API Gateway
description: 통신요금 관리 서비스 API Gateway
version: 1.0.0
encoding: UTF-8
java:
version: 17