81 lines
1.6 KiB
YAML
81 lines
1.6 KiB
YAML
# https://www.express-gateway.io/docs/configuration/gateway.config.yml/
|
||
# https://www.cnblogs.com/PLM-Teamcenter/p/16388583.html
|
||
|
||
http:
|
||
port: 8080
|
||
admin:
|
||
port: 9876
|
||
host: localhost
|
||
# 指定具体的客户端 - 绑定域名和 被映射的接口地址
|
||
apiEndpoints:
|
||
api:
|
||
host: localhost
|
||
paths: '/ip'
|
||
|
||
user_client:
|
||
host: localhost
|
||
paths:
|
||
- /user
|
||
- /user/*
|
||
|
||
articles_client:
|
||
host: localhost
|
||
paths:
|
||
- /articles
|
||
- /articles/*
|
||
|
||
# 声明网关可以管理的微服务 - 被代理的地址
|
||
serviceEndpoints:
|
||
userbin:
|
||
url: 'http://127.0.0.1:3002'
|
||
|
||
articlesbin:
|
||
url: 'http://127.0.0.1:3003'
|
||
|
||
httpbin:
|
||
url: 'https://httpbin.org'
|
||
|
||
policies:
|
||
- basic-auth
|
||
- cors
|
||
- expression
|
||
- key-auth
|
||
- log
|
||
- oauth2
|
||
- proxy
|
||
- rate-limit
|
||
|
||
# 通过管道把客户端与微服务串联起来
|
||
pipelines:
|
||
|
||
default:
|
||
apiEndpoints:
|
||
- api
|
||
policies:
|
||
# Uncomment `key-auth:` when instructed to in the Getting Started guide.
|
||
# - key-auth:
|
||
# proxy;它的作用是代理/转发请求,这里指定了将 apiEndpoints 来的请求转发到前面定义了的微服务
|
||
- proxy:
|
||
- action:
|
||
serviceEndpoint: httpbin
|
||
changeOrigin: true
|
||
|
||
pipeline_user:
|
||
apiEndpoints:
|
||
- user_client
|
||
policies:
|
||
- proxy:
|
||
- action:
|
||
serviceEndpoint: userbin
|
||
changeOrigin: true
|
||
|
||
pipeline_articles:
|
||
apiEndpoints:
|
||
- articles_client
|
||
policies:
|
||
- proxy:
|
||
- action:
|
||
serviceEndpoint: articlesbin
|
||
changeOrigin: true
|
||
|