Replies: 5 comments 1 reply
-
see https://apisix.apache.org/zh/docs/apisix/terminology/service/ |
Beta Was this translation helpful? Give feedback.
-
即便文档有,也根本看不出来区别 |
Beta Was this translation helpful? Give feedback.
-
我觉得有区别的点应该是,服务可以挂插件,而上游不能挂插件 |
Beta Was this translation helpful? Give feedback.
-
就是nginx配置文件中的upstream和server的区别,文档写得太尴尬了 |
Beta Was this translation helpful? Give feedback.
-
我理解服务是一些route/upstream共用的配置,主要是一些共用的插件配置,upstream只用于找到host+port,不配置插件的,route中插件是专用于一个路由,service的插件则可以包含作用于路由,一般情况下,例如一个域名共用的一些插件。举例: {
"id": "1",
"name": "example-service",
"desc": "This is an example service without upstream.",
"plugins": {
"limit-count": {
"count": 10,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
}
}
} 然后,在 Route 中直接指定 upstream 并引用前面定义的 Service: {
"uri": "/example1/*",
"methods": ["GET"],
"service_id": "1",
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:8080": 1
}
}
}
{
"uri": "/example2/*",
"methods": ["GET"],
"service_id": "1",
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.2:8080": 1
}
}
} 上述配置中,两个 Route 都引用了同一个 Service,这个 Service 包含了通用的插件配置,但每个 Route 都具有自己的 upstream 配置,指向不同的后端服务。 在实际的执行过程中,service的插件会融合到route中,如果有冲突route插件具有更高优先级,merge后一起执行 |
Beta Was this translation helpful? Give feedback.
-
服务的配置类似于路由,路由用于匹配url请求上游,那么服务有什么用呢
Beta Was this translation helpful? Give feedback.
All reactions