修改 nacos-federation 插件,实现 接口请求基地址从 配置中心获取,并注入到环境变量中

This commit is contained in:
编码猿
2025-09-23 03:26:10 +08:00
parent cbc2c25cf4
commit 84c4e8bdc7
22 changed files with 363 additions and 47 deletions

View File

@@ -4,7 +4,12 @@ services:
traefik:
image: traefik:v3.0
container_name: traefik
network_mode: "host" # 主机网络模式
networks:
- traefik-net
ports:
- "80:80"
- "8080:8080"
# network_mode: "host" # 主机网络模式
volumes:
- ./traefik.yml:/etc/traefik/traefik.yml
- ./dynamic.yml:/etc/traefik/dynamic.yml # 动态配置文件
@@ -16,9 +21,15 @@ services:
privileged: true
image: node:24.8.0-alpine3.21
container_name: nacos-watcher
network_mode: "host"
# network_mode: "host"
networks:
- traefik-net
working_dir: /app
volumes:
- ./:/app # 挂载当前目录到容器
command: sh -c "npm install && node src/index.js"
restart: always
restart: always
networks:
traefik-net:
driver: bridge

View File

@@ -61,7 +61,7 @@ http:
ipWhiteList:
sourceRange:
- 127.0.0.1/32
- 192.168.31.0/24
- 192.168.107.0/24
retries:
retry:
attempts: 3

View File

@@ -18,7 +18,7 @@ module.exports = {
traefikConfig: {
middlewaresStr: ['compress', 'ipWhiteList', 'rateLimit', 'retries'],
middlewaresConfig: {
// 限流中间件(独立配置,关键修复)
// 限流中间件
rateLimit: {
rateLimit: {
average: 100,
@@ -36,10 +36,10 @@ module.exports = {
minResponseBodyBytes: 1024
}
},
// IP白名单中间件示例允许本地和192.168.31网段)
// IP白名单中间件
ipWhiteList: {
ipWhiteList: {
sourceRange: ['127.0.0.1/32', '192.168.31.0/24']
sourceRange: ['127.0.0.1/32', '192.168.107.0/24']
}
},
// // 重定向中间件HTTP→HTTPS