commit | fbd0b4af24ca6f27b275e1e308f26c25fbdc20dd | [log] [tgz] |
---|---|---|
author | Sinsy <550569627@qq.com> | Mon Jun 13 23:27:20 2022 +0800 |
committer | GitHub <noreply@github.com> | Mon Jun 13 23:27:20 2022 +0800 |
tree | 70fe8ba96a040ad2f4d5f7cf72e393a8b3e3d13b | |
parent | a937665fa8f98abbb91a6310b8acb81dd629e484 [diff] |
Update README.md
ShenYu(Incubator) is High-Performance Java API Gateway.
ShenYu Nginx is an Nginx Upstream module for ShenYu instances discovery. The module will discover ShenYu instances to be upstream server of Nginx throght watching register, such as Etcd(supported), Apache Zookeeper(Todo), Nacos(Todo), and others.
The first, clone the source from Github.
git clone https://github.com/apache/incubator-shenyu-nginx
Then, build from source and install.
cd incubator-shenyu-nginx luarocks make rockspec/shenyu-nginx-main-0.rockspec
Modify the Nginx configure, create and initialize the ShenYu Register to connect to targed register center. Here is an example for Etcd.
init_worker_by_lua_block { local register = require("shenyu.register.etcd") register.init({ balancer_type = "chash", etcd_base_url = "http://127.0.0.1:2379", }) }
balancer_type
specify the balancer. It has supported chash
and round robin
.etcd_base_url
specify the Etcd server.Modify the upstream
to enable to update upstream servers dynamically. This case will synchorinze the ShenYu instance list with register center. And then pick one up for handling the request.
upstream shenyu { server 0.0.0.1; -- bad balancer_by_lua_block { require("shenyu.register.etcd").pick_and_set_peer() } }
Finally, restart OpenResty.
openresty -s reload
Here provides a completed examples.