Usage record of VX-API-Gateway open source gateway technology

Usage record of VX-API-Gateway open source gateway technology

Insert image description here

Official website address https://mirren.gitee.io/vx-api-gateway-doc/

VX-API-Gateway(以下称为VX-API)是基于Vert.x (java)开发的
API网关,
是一个分布式、全异步、高性能、可扩展、轻量级的可视化配置的API网关服务

Official website download program zip package

Visit https://gitee.com/mirren/VX-API-Gateway/releases

Download the latest program zip package

Insert image description here

Installation and use

Find a directory to unzip the package

Insert image description here

Start.bat or start.sh in the bin directory of the startup program

Insert image description here
Insert image description here

Browser access port 5256

Insert image description here
After clicking to enter the homepage, you will enter
http://localhost:5256/static/Application.html
and be prompted to log in. The default account is VXAdmin and the password is hivx.
Insert image description here

The login password is configured in user.json under conf in the installation directory.
Insert image description here

After logging in, you can create a new application

新建应用是指 你的vx-api-gateway网关要对接的服务名或应用名以及相关信息配置

Create app

Insert image description here
Insert image description here
Insert image description here
You don’t need to fill in the http parameter settings of the vx gateway proxy. The default parameter settings will be automatically used (if you need to modify them, you can fill them in as needed)
Insert image description here
Insert image description here

Insert image description here
After the application is created, you can see it in the application list

Create an API proxy under the application

Click API management to create an API on the application you just created.
Insert image description here
Insert image description here

Create a get request proxy
目标:访问/sgate/t1 后自动代理到真实后端的/demo/t1

Insert image description here
Insert image description here
Insert image description here
Insert image description here
The return result configuration of the proxy API does not need to be specially modified. By default, the data of the back-end real API will be automatically returned.

Insert image description here
After the creation is completed, you can see it in the api list.
Finally, you need to enable the application you just created and the API proxy under the application.

Click to start the application on the application details page.
Insert image description here
Click to start an API proxy on the API details page
Insert image description here
. After the startup is completed, click on the running status page to observe the running status of the current vx-api-gateway.
Insert image description here
Finally, you can use postman to test whether the proxy is successful.
Visit
http:/ /127.0.0.1:8330/sgate/t1
automatically proxies to the real backend
http://127.0.0.1:8085/demo/t1
and returns the data of the real service interface of the backend.

Insert image description here
Actual testing found that the proxy can be successfully used and the request takes 188ms.

You can also see the relevant gateway logs on the API details page as follows:
Insert image description here

VX-API-Gateway technical architecture

ApplicationApplication

应用可以理解为分组,是VX-AP中的一个运行单元,一个应用相当于一个服务器(Server)不同的是他的端口号允许被重复使用,也就是说在VX-API中一个端口号可以给任意应用绑定(前提是这个端口号没有被别的程序绑定),应用用于管理API
访问http://localhost:端口号(默认5256)/static/Application.html或者通过http://localhost:端口号(默认5256)进入后便可以查看与管理应用

API interface

API是VX-API的服务核心,创建应用后便可以在应用的API管理中创建API;
当前版本中API支持三种服务类型,
HTTP/HTTPS服务(既VX-API需要去请到后台服务器的类型):参数检查与透传,支持带权重的负载均衡访问策略,轮询与IP哈希化,自动断路与重试不可用的后台服务地址
页面跳转服务:当用户访问时redirect到指定页面
自定义服务:可以自定义任意服务,当前版本中实现了,基于session-token的认证授权,获取服务器时间戳,与获取常量
同时API支持全局黑名单,流量限制,权限认证,自定义前置/后置处理器等

API execution process

Insert image description here
The green line represents that it will definitely be executed, and the black line represents that it will be executed when it exists. When the user requests, the complete process is executed from 1 to 7 in the order of components. If any component is not satisfied, the request ends and responds (fail-end- response), when an exception occurs in any component, it uniformly enters the exception component (Exception Handler). The request ends and the error message is responded. For
more API execution process introduction, please refer to the API component introduction below.

Summarize

VX-API-Gateway 是一个轻量的,支持可视化配置的网关代理服务。
可以代理多个后端应用,同时可以对每个后端应用的API做精细化的API代理配置。
由于VX-API-Gateway 底层使用的是vert.x技术,所以不必担心性能问题

Guess you like

Origin blog.csdn.net/ThinkPet/article/details/132115266