From f7cdfcbd1de5ec400b89806a3ac753a77ee5c5ab Mon Sep 17 00:00:00 2001 From: fanfpy Date: Tue, 1 Jul 2025 15:43:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor(consul):=20=E7=BB=9F=E4=B8=80Traefik?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E9=85=8D=E7=BD=AE=E6=A0=BC=E5=BC=8F=E5=B9=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0whoami=E6=9C=8D=E5=8A=A1=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将Traefik路由规则从下划线格式改为点分隔格式 - 更新whoami服务配置,使用tags替代meta并添加中间件配置 - 修复user-service和recommend-service中的拼写错误 --- consul/config/data-service.json | 2 +- consul/config/emotion-service.json | 2 +- consul/config/frontend.json | 2 +- consul/config/quant-service.json | 2 +- consul/config/recommend-service.json | 2 +- consul/config/user-service.json | 2 +- consul/config/whoami.json | 22 +++++++++++++++------- 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/consul/config/data-service.json b/consul/config/data-service.json index 437bd59..52ba919 100644 --- a/consul/config/data-service.json +++ b/consul/config/data-service.json @@ -9,7 +9,7 @@ "id": "data-service-1", "meta": { "traefik_enable": "true", - "traefik_http_routers_data_service_rule": "PathPrefix('/api/data')" + "traefik.http.routers.data-service.rule": "PathPrefix('/api/data')" }, "name": "data-service", "port": 8000 diff --git a/consul/config/emotion-service.json b/consul/config/emotion-service.json index 258d5c5..1818fb5 100644 --- a/consul/config/emotion-service.json +++ b/consul/config/emotion-service.json @@ -9,7 +9,7 @@ "id": "emotion-service-1", "meta": { "traefik_enable": "true", - "traefik_http_routers_emotion_service_rule": "PathPrefix(`/api/emotion`)" + "traefik.http.routers.emotion-service.rule": "PathPrefix('/api/emotion')" }, "name": "emotion-service", "port": 8002 diff --git a/consul/config/frontend.json b/consul/config/frontend.json index 51d7769..93efea8 100644 --- a/consul/config/frontend.json +++ b/consul/config/frontend.json @@ -9,7 +9,7 @@ "id": "frontend-1", "meta": { "traefik_enable": "true", - "traefik_http_routers_frontend_rule": "PathPrefix(`/`)" + "traefik.http.routers.frontend.rule": "PathPrefix('/')" }, "name": "frontend", "port": 80 diff --git a/consul/config/quant-service.json b/consul/config/quant-service.json index ed70c98..fe78f67 100644 --- a/consul/config/quant-service.json +++ b/consul/config/quant-service.json @@ -9,7 +9,7 @@ "id": "quant-service-1", "meta": { "traefik_enable": "true", - "traefik_http_routers_quant_service_rule": "PathPrefix(`/api/quant`)" + "traefik.http.routers.quant-service.rule": "PathPrefix('/api/quant')" }, "name": "quant-service", "port": 8001 diff --git a/consul/config/recommend-service.json b/consul/config/recommend-service.json index 897d1c9..923320d 100644 --- a/consul/config/recommend-service.json +++ b/consul/config/recommend-service.json @@ -9,7 +9,7 @@ "id": "recommend-service-1", "meta": { "traefik_enable": "true", - "traefik_http_routers_recommend_service_rule": "PathPrefix(`/api/recommend`)" + "raefik.http.routers.quant-service.rule": "PathPrefix(`/api/recommend`)" }, "name": "recommend-service", "port": 8003 diff --git a/consul/config/user-service.json b/consul/config/user-service.json index 0d96995..00cbcc3 100644 --- a/consul/config/user-service.json +++ b/consul/config/user-service.json @@ -9,7 +9,7 @@ "id": "user-service-1", "meta": { "traefik_enable": "true", - "traefik_http_routers_user_service_rule": "PathPrefix(`/api/user`)" + "raefik.http.routers.quant-service.rule": "PathPrefix(`/api/user`)" }, "name": "user-service", "port": 8004 diff --git a/consul/config/whoami.json b/consul/config/whoami.json index ed690e5..2fb6d29 100644 --- a/consul/config/whoami.json +++ b/consul/config/whoami.json @@ -1,15 +1,23 @@ { "service": { "name": "whoami", + "address": "whoami", "port": 80, - "meta": { - "traefik_enable": "true", - "traefik_http_routers_whoami_rule": "PathPrefix(`/whoami`)", - "traefik_http_routers_whoami_entrypoints": "web" - }, + "tags": [ + "traefik.enable=true", + "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)", + "traefik.http.routers.whoami.entrypoints=web", + "traefik.http.routers.whoami.middlewares=whoami-prefix" + ], "check": { - "http": "http://whoami:80", + "http": "http://whoami:80/", "interval": "10s" } + }, + "middleware": { + "name": "whoami-prefix", + "pathPrefixStrip": { + "prefixes": ["/whoami"] + } } -} \ No newline at end of file +}