本文共 1888 字,大约阅读时间需要 6 分钟。
mkdir -p /kong
mkdir -p /log/kong/kong
rpm -ivh --prefix=/kong kong-2.0.3.el7.amd64.rpm
配置文件目录:/kong/etc/kong
prefix =/kong
database = off declarative_config = /kong/etc/kong/kong.yml admin_listen = = 0.0.0.0:8001, 0.0.0.0:8444 ssl proxy_listen = 0.0.0.0:8080, 0.0.0.0:8443 sslhost路由方式
services:- name: service1 url: 实际地址 # Entities can store tags as metadata tags: - service1 # Entities that have a foreign-key relationship can be nested: routes: - name: service1-route # Relationships can also be specified between top-level entities, # either by name or by id service: service1 hosts: [服务域名]- name: service2 url: xx.xx.xx.xx tags: - service2 routes: - name: service2-route service: service2 hosts: [服务域名]
Path的路由方式
services:- host: xx.xx.xx.xx name: example-service port: xxxxxx protocol: http # Entities can store tags as metadata tags: - example # Entities that have a foreign-key relationship can be nested: routes: - name: example-route paths: - /mock
负载均衡的配置模板
services:- host: upstream name: example-service port: xxxx protocol: http # Entities can store tags as metadata tags: - example # Entities that have a foreign-key relationship can be nested: routes: - name: example-route paths: - /mockupstreams:- name: upstream targets: - target: xx.xx.xx.xx(实际地址) weight: 100 - target: xx.xx.xx.xx(实际地址) weight: 100
启动: kong start -c kong.conf
停止: kong stop 重启: kong restart -c kong.conf 检查kong的状态: kong check <path/to/kong.conf>7.1、hostname方式的验证
通过浏览器,记得将host改成对应的域名。 修改host的路径:C:\Windows\System32\drivers\etchttp://域名/
7.1、curl方式的验证
curl -i -X GET http://:8000/mock/requesthttps://docs.konghq.com/getting-started-guide/2.1.x/expose-services/
转载地址:http://bylcn.baihongyu.com/