feat: add gateway-service (Spring Cloud Gateway + Consul)
This commit is contained in:
15
gateway-service/src/main/resources/application-prod.yml
Normal file
15
gateway-service/src/main/resources/application-prod.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
spring:
|
||||
cloud:
|
||||
consul:
|
||||
host: ${CONSUL_HOST:consul}
|
||||
port: ${CONSUL_PORT:8500}
|
||||
|
||||
gateway:
|
||||
cors:
|
||||
allowed-origins: ${CORS_ORIGINS:https://balexvic.com}
|
||||
|
||||
logging:
|
||||
level:
|
||||
root: WARN
|
||||
com.posthub.gateway: INFO
|
||||
org.springframework.cloud.gateway: WARN
|
||||
86
gateway-service/src/main/resources/application.yml
Normal file
86
gateway-service/src/main/resources/application.yml
Normal 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
|
||||
14
gateway-service/src/main/resources/logback.xml
Normal file
14
gateway-service/src/main/resources/logback.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"/>
|
||||
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user