chore(config): Improve Nacos high availability deployment

This commit is contained in:
2026-03-17 17:26:49 +08:00
parent f7751cb633
commit 88bb0c0cd0
23 changed files with 609 additions and 1579 deletions
@@ -1,15 +0,0 @@
spring:
cloud:
sentinel:
log:
dir: ./logs/sentinel/
switch-pid: true
gateway:
httpclient:
connect-timeout: 60000
response-timeout: 60000
logging:
level:
org.springframework.cloud.gateway: debug
reactor.netty.http.client: debug
@@ -1,87 +0,0 @@
server:
port: 9000
spring:
application:
name: video-gateway
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVERS:192.168.1.101:8848,192.168.1.102:8848,192.168.1.103:8848}
namespace: ${NACOS_NAMESPACE:public}
group: ${NACOS_GROUP:DEFAULT_GROUP}
username: nacos
password: nacos
ip: ${GATEWAY_IP:}
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
namespace: ${spring.cloud.nacos.discovery.namespace}
group: ${spring.cloud.nacos.discovery.group}
file-extension: yaml
username: nacos
password: nacos
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
routes:
- id: video-auth
uri: lb://video-auth
predicates:
- Path=/auth/**
- id: video-user
uri: lb://video-user
predicates:
- Path=/user/**
- id: video-content
uri: lb://video-content
predicates:
- Path=/content/**
- id: video-comment
uri: lb://video-comment
predicates:
- Path=/comment/**
- id: video-recommend
uri: lb://video-recommend
predicates:
- Path=/recommend/**
- id: video-admin
uri: lb://video-admin
predicates:
- Path=/admin/**
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: 8720
client-ip: ${GATEWAY_IP:}
eager: true
scg:
fallback:
mode: response
response-body: '{"code":500,"message":"服务不可用,请稍后再试"}'
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: always
gateway:
enabled: true
gateway:
ignore:
urls:
- /**/auth/login
- /**/auth/register
- /**/auth/captcha
- /content/video/public/**
- /content/category/tree
- /content/category/list
- /comment/reply/public/**
- /comment/public/**
- /admin/auth/captcha
- /admin/auth/login
@@ -5,15 +5,16 @@ spring:
application:
name: video-gateway
profiles:
active: dev
active: ${SPRING_PROFILES_ACTIVE:dev}
config:
import:
- optional:nacos:${spring.application.name}.yaml?username=${NACOS_USERNAME:nacos}&password=${NACOS_PASSWORD:nacos}
- optional:nacos:common.yaml?refreshEnabled=true
- optional:nacos:${spring.application.name}.yaml?refreshEnabled=true
cloud:
nacos:
discovery:
server-addr: ${NACOS_HOST:5.180.253.115}:${NACOS_PORT:8848}
namespace: ${NACOS_NAMESPACE:public}
server-addr: ${NACOS_SERVER_ADDR:${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}}
namespace: ${NACOS_NAMESPACE:}
group: ${NACOS_GROUP:DEFAULT_GROUP}
username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos}
@@ -25,56 +26,6 @@ spring:
file-extension: yaml
username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos}
extension-configs:
- data-id: video-gateway.yaml
group: ${NACOS_GROUP:DEFAULT_GROUP}
refresh: true
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
routes:
- id: video-auth
uri: lb://video-auth
predicates:
- Path=/auth/**
# 移除 StripPrefix 过滤器
- id: video-user
uri: lb://video-user
predicates:
- Path=/user/**
# 移除 StripPrefix 过滤器
- id: video-content
uri: lb://video-content
predicates:
- Path=/content/**
# 移除 StripPrefix 过滤器
- id: video-comment
uri: lb://video-comment
predicates:
- Path=/comment/**
# 移除 StripPrefix 过滤器
- id: video-recommend
uri: lb://video-recommend
predicates:
- Path=/recommend/**
# 移除 StripPrefix 过滤器
- id: video-admin
uri: lb://video-admin
predicates:
- Path=/admin/**
# 移除 StripPrefix 过滤器
sentinel:
transport:
dashboard: ${SENTINEL_DASHBOARD_HOST:5.180.253.115}:${SENTINEL_DASHBOARD_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8719}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
scg:
fallback:
mode: response
response-body: '{"code":500,"message":"服务不可用,请稍后再试"}'
management:
endpoints:
@@ -86,18 +37,3 @@ management:
show-details: always
gateway:
enabled: true
# 不需要鉴权的URL列表
gateway:
ignore:
urls:
- /**/auth/login
- /**/auth/register
- /**/auth/captcha
- /content/video/public/**
- /content/category/tree
- /content/category/list
- /comment/reply/public/**
- /comment/public/**
- /admin/auth/captcha
- /admin/auth/login