Update README.md
1 file changed
tree: 70fe8ba96a040ad2f4d5f7cf72e393a8b3e3d13b
  1. .github/
  2. example/
  3. lib/
  4. rockspec/
  5. test/
  6. .asf.yaml
  7. .gitignore
  8. DISCLAIMER
  9. LICENSE
  10. NOTICE
  11. README.md
README.md

incubator-shenyu-nginx

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.

Getting Started

  • Prerequisite:
  1. Luarocks
  2. OpenResty

Build from source

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",
    })
}
  1. balancer_type specify the balancer. It has supported chash and round robin.
  2. 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.

Contributor and Support

License

Apache License 2.0