tiancheng91 / collection

笔记
https://github.com/tiancheng91/collection/issues
22 stars 1 forks source link

kong gateway #30

Open tiancheng91 opened 5 years ago

tiancheng91 commented 5 years ago

quick start

  1. add service

    curl -i -X POST \
    --url http://localhost:8001/services/ \
    --data 'name=example-service' \
    --data 'url=http://mockbin.org'
  2. Add a Route for the Service (一个服务可以给添加到多个路由上)

    curl -i -X POST \
    --url http://localhost:8001/services/example-service/routes \
    --data 'hosts[]=example.com&path=/'
  3. enable plugin

    curl -i -X POST \
    --url http://localhost:8001/services/example-service/plugins/ \
    --data 'name=key-auth'
  4. consumer (某个服务的某个用户)

    
    curl -i -X POST \
    --url http://localhost:8001/consumers/ \
    --data "username=test"

curl -i -X POST \ --url http://localhost:8001/consumers/test/key-auth/ \ --data 'key=test'

curl -i -H "apikey: test" -H "Host: example.com" localost


5: Certificate
```bash
# 新增证书
curl -i -X POST \
--url http://localhost:8001/certificates \
--data 'cert=pem_public_cert&key=pem_private_key&sni[]=*.domain.com'
# 更新证书
curl -i -X PUT /certificates/{certificate id} 
  1. upstream 同名service的请求会转发到upstream上, 负载均衡用