kong 负载均衡
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了kong 负载均衡相关的知识,希望对你有一定的参考价值。
首先创建upstream
curl -i -X POST --url http://localhost:8001/upstreams/ -d "name=user_service_upstream"
之后添加后端服务
curl -i -X POST --url http://localhost:8001/upstreams/user_service_upstream/targets -d "target=192.168.195.129:80"
curl -i -X POST --url http://localhost:8001/upstreams/user_service_upstream/targets -d "target=192.168.195.130:80"
查看upstream 里面的target
curl -i -X GET --url http://localhost:8001/upstreams/user_service_upstream/targets/
添加到api
curl -i -X POST --url http://localhost:8001/apis/ -d "name=user_service_lb" -d "hosts=www.test.com" -d "upstream_url=http://user_service_upstream"
ps -ef | grep nginx
cd /usr/local/openresty/nginx/conf/
vi nginx.conf
在最后添加
include vhosts/*.conf;
注:大括号里面
mkdir vhosts
cd vhosts/
vi nginx.conf
server {
listen 80;
server_name www.test.com;
location / {
proxy_pass http://www.test.com:8000;
}
}
/usr/local/openresty/nginx/sbin/nginx -t
/usr/local/openresty/nginx/sbin/nginx
vi /etc/hosts
192.168.195.128 www.test.com
以上是关于kong 负载均衡的主要内容,如果未能解决你的问题,请参考以下文章