feat: add gateway-service (Spring Cloud Gateway + Consul)

This commit is contained in:
2026-02-17 19:34:49 +01:00
parent 5a05bb2147
commit 008aceb64b
11 changed files with 464 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
server:
port: 8080
forward-headers-strategy: framework
spring:
application:
name: gateway-service
cloud:
consul:
host: ${CONSUL_HOST:localhost}
port: ${CONSUL_PORT:8500}
discovery:
register: true
enabled: true
health-check-path: /actuator/health
health-check-interval: 15s
prefer-ip-address: true
instance-id: ${spring.application.name}:${random.value}
# Spring Cloud Gateway 2025.0 — new prefix: spring.cloud.gateway.server.webflux
gateway:
server:
webflux:
# Trust Nginx reverse proxy for forwarded headers
trusted-proxies: 127\.0\.0\.1|10\.0\.0\..*|172\.1[6-9]\..*|172\.2[0-9]\..*|172\.3[0-1]\..*|192\.168\..*
discovery:
locator:
enabled: true
lower-case-service-id: true
httpclient:
connect-timeout: 5000
response-timeout: 60s
default-filters:
- DedupeResponseHeader=Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST
routes:
# RAG Service - actuator (health, info)
- id: rag-service-actuator
uri: lb://rag-service
predicates:
- Path=/api/rag/actuator/**
filters:
- RewritePath=/api/rag/actuator(?<segment>/?.*), /actuator${segment}
# RAG Service - API endpoints
- id: rag-service-api
uri: lb://rag-service
predicates:
- Path=/api/rag/**
- Method=GET,POST,PUT,DELETE
filters:
- RewritePath=/api/rag(?<segment>/?.*), ${segment}
# Analytics Service (will be added later)
# - id: analytics-service-api
# uri: lb://analytics-service
# predicates:
# - Path=/api/analytics/**
# - Method=GET,POST
# filters:
# - RewritePath=/api/analytics(?<segment>/?.*), ${segment}
gateway:
cors:
allowed-origins: ${CORS_ORIGINS:*}
management:
endpoints:
web:
exposure:
include: health,info,gateway
endpoint:
health:
show-details: always
gateway:
enabled: true
logging:
level:
root: INFO
com.posthub.gateway: DEBUG
org.springframework.cloud.gateway: INFO