refactor(consul): 将主机路由规则改为路径前缀并添加中间件
修改所有服务的路由规则,从基于主机名改为基于路径前缀 为每个服务添加strip前缀中间件以正确处理API请求
This commit is contained in:
parent
f63863e647
commit
1819c9e111
@ -9,8 +9,10 @@
|
||||
"id": "data-service-1",
|
||||
"tags": [
|
||||
"traefik.enable=true",
|
||||
"traefik.http.routers.data-service.rule=Host(\"data.aristockai.com\")",
|
||||
"traefik.http.routers.data-service.entrypoints=web"
|
||||
"traefik.http.routers.data-service.rule=PathPrefix(`/api/data`) || PathPrefix(`/api/public`)",
|
||||
"traefik.http.routers.data-service.entrypoints=web",
|
||||
"traefik.http.middlewares.data-service-stripprefix.stripprefix.prefixes=/api/data,/api/public",
|
||||
"traefik.http.routers.data-service.middlewares=data-service-stripprefix@consulcatalog"
|
||||
],
|
||||
"name": "data-service",
|
||||
"port": 8000
|
||||
|
||||
@ -9,8 +9,10 @@
|
||||
"id": "emotion-service-1",
|
||||
"tags": [
|
||||
"traefik.enable=true",
|
||||
"traefik.http.routers.emotion-service.rule=Host(\"emotion.aristockai.com\")",
|
||||
"traefik.http.routers.emotion-service.entrypoints=web"
|
||||
"traefik.http.routers.emotion-service.rule=PathPrefix(`/api/emotion`) || PathPrefix(`/api/sentiment`)",
|
||||
"traefik.http.routers.emotion-service.entrypoints=web",
|
||||
"traefik.http.middlewares.emotion-service-stripprefix.stripprefix.prefixes=/api/emotion,/api/sentiment",
|
||||
"traefik.http.routers.emotion-service.middlewares=emotion-service-stripprefix@consulcatalog"
|
||||
],
|
||||
"name": "emotion-service",
|
||||
"port": 8002
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
"id": "frontend-1",
|
||||
"tags": [
|
||||
"traefik.enable=true",
|
||||
"traefik.http.routers.frontend.rule=Host(\"aristockai.com\") || Host(\"www.aristockai.com\")",
|
||||
"traefik.http.routers.frontend.rule=PathPrefix(`/`) || PathPrefix(`/index.html`) || PathPrefix(`/static`)",
|
||||
"traefik.http.routers.frontend.entrypoints=web"
|
||||
],
|
||||
"name": "frontend",
|
||||
|
||||
@ -9,8 +9,10 @@
|
||||
"id": "quant-service-1",
|
||||
"tags": [
|
||||
"traefik.enable=true",
|
||||
"traefik.http.routers.quant-service.rule=Host(\"quant.aristockai.com\")",
|
||||
"traefik.http.routers.quant-service.entrypoints=web"
|
||||
"traefik.http.routers.quant-service.rule=PathPrefix(`/api/quant`) || PathPrefix(`/api/strategy`)",
|
||||
"traefik.http.routers.quant-service.entrypoints=web",
|
||||
"traefik.http.middlewares.quant-service-stripprefix.stripprefix.prefixes=/api/quant,/api/strategy",
|
||||
"traefik.http.routers.quant-service.middlewares=quant-service-stripprefix@consulcatalog"
|
||||
],
|
||||
"name": "quant-service",
|
||||
"port": 8001
|
||||
|
||||
@ -9,8 +9,10 @@
|
||||
"id": "recommend-service-1",
|
||||
"tags": [
|
||||
"traefik.enable=true",
|
||||
"traefik.http.routers.recommend-service.rule=Host(\"recommend.aristockai.com\")",
|
||||
"traefik.http.routers.recommend-service.entrypoints=web"
|
||||
"traefik.http.routers.recommend-service.rule=PathPrefix(`/api/recommend`) || PathPrefix(`/api/suggest`)",
|
||||
"traefik.http.routers.recommend-service.entrypoints=web",
|
||||
"traefik.http.middlewares.recommend-service-stripprefix.stripprefix.prefixes=/api/recommend,/api/suggest",
|
||||
"traefik.http.routers.recommend-service.middlewares=recommend-service-stripprefix@consulcatalog"
|
||||
],
|
||||
"name": "recommend-service",
|
||||
"port": 8003
|
||||
|
||||
@ -9,8 +9,10 @@
|
||||
"id": "user-service-1",
|
||||
"tags": [
|
||||
"traefik.enable=true",
|
||||
"traefik.http.routers.user-service.rule=Host(\"user.aristockai.com\")",
|
||||
"traefik.http.routers.user-service.entrypoints=web"
|
||||
"traefik.http.routers.user-service.rule=PathPrefix(`/api/user`) || PathPrefix(`/api/auth`)",
|
||||
"traefik.http.routers.user-service.entrypoints=web",
|
||||
"traefik.http.middlewares.user-service-stripprefix.stripprefix.prefixes=/api/user,/api/auth",
|
||||
"traefik.http.routers.user-service.middlewares=user-service-stripprefix@consulcatalog"
|
||||
],
|
||||
"name": "user-service",
|
||||
"port": 8004
|
||||
|
||||
Loading…
Reference in New Issue
Block a user