From dc04f20856f40e76f975515048a617d8ef1c7e5c Mon Sep 17 00:00:00 2001 From: fanfpy Date: Sun, 6 Jul 2025 12:42:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(traefik):=20=E4=BF=AE=E6=AD=A3=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E5=8F=A3=E6=B3=A8=E9=87=8A=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=B7=AF=E7=94=B1=E8=A7=84=E5=88=99=E4=B8=BA=E5=9F=BA?= =?UTF-8?q?=E4=BA=8E=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将docker-compose.yml中的错误注释修正为服务端口注释 将所有服务的路由规则从PathPrefix改为基于域名的Host规则 移除data-service中不再需要的路径前缀中间件配置 --- consul/config/data-service.json | 6 ++---- 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 +- docker-compose.yml | 2 +- 7 files changed, 8 insertions(+), 10 deletions(-) diff --git a/consul/config/data-service.json b/consul/config/data-service.json index 16bfa16..149ae67 100644 --- a/consul/config/data-service.json +++ b/consul/config/data-service.json @@ -9,10 +9,8 @@ "id": "data-service-1", "tags": [ "traefik.enable=true", - "traefik.http.routers.data-service.rule=PathPrefix(\"/api/data\")", - "traefik.http.routers.data-service.entrypoints=web", - "traefik.http.middlewares.data-service-strip.stripprefix.prefixes=/api/data", - "traefik.http.routers.data-service.middlewares=data-service-strip" + "traefik.http.routers.data-service.rule=Host(\"data.aristockai.com\")", + "traefik.http.routers.data-service.entrypoints=web" ], "name": "data-service", "port": 8000 diff --git a/consul/config/emotion-service.json b/consul/config/emotion-service.json index 4346591..0919352 100644 --- a/consul/config/emotion-service.json +++ b/consul/config/emotion-service.json @@ -9,7 +9,7 @@ "id": "emotion-service-1", "tags": [ "traefik.enable=true", - "traefik.http.routers.emotion-service.rule=PathPrefix(\"/api/emotion\")", + "traefik.http.routers.emotion-service.rule=Host(\"emotion.aristockai.com\")", "traefik.http.routers.emotion-service.entrypoints=web" ], "name": "emotion-service", diff --git a/consul/config/frontend.json b/consul/config/frontend.json index 9263a19..e191e41 100644 --- a/consul/config/frontend.json +++ b/consul/config/frontend.json @@ -9,7 +9,7 @@ "id": "frontend-1", "tags": [ "traefik.enable=true", - "traefik.http.routers.frontend.rule=PathPrefix(\"/frontend\")", + "traefik.http.routers.frontend.rule=Host(\"aristockai.com\") || Host(\"www.aristockai.com\")", "traefik.http.routers.frontend.entrypoints=web" ], "name": "frontend", diff --git a/consul/config/quant-service.json b/consul/config/quant-service.json index 521438d..ef7a1ea 100644 --- a/consul/config/quant-service.json +++ b/consul/config/quant-service.json @@ -9,7 +9,7 @@ "id": "quant-service-1", "tags": [ "traefik.enable=true", - "traefik.http.routers.quant-service.rule=PathPrefix(\"/api/quant\")", + "traefik.http.routers.quant-service.rule=Host(\"quant.aristockai.com\")", "traefik.http.routers.quant-service.entrypoints=web" ], "name": "quant-service", diff --git a/consul/config/recommend-service.json b/consul/config/recommend-service.json index 317ff02..61dfe90 100644 --- a/consul/config/recommend-service.json +++ b/consul/config/recommend-service.json @@ -9,7 +9,7 @@ "id": "recommend-service-1", "tags": [ "traefik.enable=true", - "traefik.http.routers.recommend-service.rule=PathPrefix(\"/api/recommend\")", + "traefik.http.routers.recommend-service.rule=Host(\"recommend.aristockai.com\")", "traefik.http.routers.recommend-service.entrypoints=web" ], "name": "recommend-service", diff --git a/consul/config/user-service.json b/consul/config/user-service.json index dfbbb68..0384d27 100644 --- a/consul/config/user-service.json +++ b/consul/config/user-service.json @@ -9,7 +9,7 @@ "id": "user-service-1", "tags": [ "traefik.enable=true", - "traefik.http.routers.user-service.rule=PathPrefix(\"/api/user\")", + "traefik.http.routers.user-service.rule=Host(\"user.aristockai.com\")", "traefik.http.routers.user-service.entrypoints=web" ], "name": "user-service", diff --git a/docker-compose.yml b/docker-compose.yml index f0d786d..babba39 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -42,7 +42,7 @@ services: container_name: ari-data-service restart: always ports: - - "8000:8000" # Traefik dashboard + - "8000:8000" # 错误:应为服务端口注释而非Traefik dashboard networks: - microservice-network environment: