Gateway construction method and device based on APISIX and storage medium

Through the APISIX-based gateway construction method, using preset configuration web pages to obtain gateway parameters and set modules, the bottlenecks of traditional gateways in performance, maintainability and scalability are solved, and the high availability configuration and high performance forwarding of gateways are realized. , suitable for different service platform systems.

CN119420650APending Publication Date: 2025-02-11ZHONGDIAN DATA IND CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411532210.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

Traditional gateways have bottlenecks in performance, maintainability and scalability, especially when configuring different service platform systems, they need to make complex modifications and design of background programs, with high technical thresholds and difficult for operators to non-professional personnel. Adjust gateway parameters.

Method used

Using the APISIX-based gateway construction method, the gateway parameters are obtained through preset configuration web pages, and the etcd storage module, API communication module and Nginx collaboration module are set through these parameters to realize the high availability configuration and high performance forwarding of the gateway.

Benefits of technology

It lowers the technical threshold for gateway construction, enables users to quickly adjust gateway parameters according to business scenarios, realizes high availability configuration and high performance forwarding of gateways, and is suitable for different service platform systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119420650A_ABST
    Figure CN119420650A_ABST
Patent Text Reader

Abstract

The invention discloses a gateway construction method and device based on APISIX and a storage medium, and relates to the technical field of communication networks, and the gateway construction method based on APISIX comprises the steps: obtaining gateway parameters through a preset configuration webpage; setting the etcd storage module through the gateway parameters, and storing routing information; the gateway module is used for receiving gateway parameters, the API communication module is set through the gateway parameters, the Nginx collaboration module is set through the gateway parameters, and the routing information is obtained through collaboration between the Nginx collaboration module and the API communication module. The technical threshold of gateway construction can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication network technology, and in particular to a gateway construction method, device and storage medium based on APISIX. Background Art

[0002] In the service platform system, traditional gateways may have performance bottlenecks and poor scalability. Dynamic routing configuration, load balancing and other technologies are needed to implement high-performance gateways and solve problems in performance, maintainability and scalability.

[0003] In order to solve the performance bottleneck and poor scalability of traditional gateways, dynamic routing configuration technology is usually used, such as dynamic routing based on Etcd, to update routing rules in real time without restarting the service or manually changing the configuration file. However, when configuring different service platform systems, the background program needs to be modified and designed, and the designer needs to have the ability to develop communication network technology. The technical threshold is relatively high. However, considering that the operators of the service platform system involve multiple industries such as online shopping, financial services, content hosting, social networks, and online games, the operators are not professionals in the field of communication network technology, and they need to adjust the parameters of the gateway in the service platform system during daily service platform system operations. How to enable people in different fields to build gateways suitable for their own service platform systems is a problem worthy of attention.

[0004] Therefore, how to quickly adjust gateway parameters according to business scenarios to achieve high-availability configuration and high-performance forwarding of the gateway is a problem that needs to be solved urgently. Summary of the invention

[0005] The main purpose of this application is to provide a gateway construction method, device and storage medium based on APISIX, aiming to solve the technical problem of quickly adjusting gateway parameters according to business scenarios and achieving high-availability configuration and high-performance forwarding of the gateway.

[0006] To achieve the above objectives, the present application provides a gateway construction method based on APISIX, and the gateway construction method based on APISIX includes:

[0007] Obtain gateway parameters through the preset configuration webpage;

[0008] The etcd storage module is set through the gateway parameters to store routing information;

[0009] The API communication module is set through the gateway parameters, and the Nginx collaboration module is set through the gateway parameters. The Nginx collaboration module collaborates with the API communication module to obtain the routing information.

[0010] In one embodiment, the gateway parameters include a storage path, a communication port, and a communication protocol, and the step of setting the etcd storage module through the gateway parameters includes:

[0011] The API communication module and the etcd storage module are connected through the communication port and the communication protocol, the etcd storage module is configured through the storage path, and the etcd storage module stores the routing information according to the storage path.

[0012] In one embodiment, the gateway parameters include a request address and a forwarding address, and the step of setting the API communication module through the gateway parameters includes:

[0013] Obtain the routing information from the etcd storage module through the communication port and communication protocol;

[0014] A communication path is constructed between the request address and the forwarding address through the routing information, and the API communication module setting is completed.

[0015] In one embodiment, the step of setting the Nginx collaboration module includes:

[0016] Dynamically constructing an Nginx collaborative module configuration through the routing information, adding or updating a location block and an upstream definition in the Nginx collaborative module configuration;

[0017] The Nginx collaborative module is set through the Nginx collaborative module configuration.

[0018] In one embodiment, the gateway includes a virtual machine module, and the step of configuring the Nginx collaborative module through the Nginx collaborative module further includes:

[0019] If the routing information changes, the Nginx collaboration module configuration is hot updated through the virtual machine module to obtain the updated configuration and trigger script;

[0020] The trigger script is used to trigger the Nginx collaborative module to reload, and the update configuration is loaded into the Nginx collaborative module update setting.

[0021] In one embodiment, the routing information includes routing rules, the gateway includes a timer module, the API communication module includes a routing table, the API communication module is set by the gateway parameters, and the Nginx collaboration module is set, and the steps of completing the construction of the gateway include:

[0022] The routing information in the etcd storage module is periodically queried through the timer module;

[0023] When the routing rule changes, the API communication module updates the routing table.

[0024] In one embodiment, the method further comprises:

[0025] The etcd storage module is monitored through a preset monitoring function, and when the routing information changes, the API communication module is executed to update the routing table.

[0026] In one embodiment, the gateway parameters include authority verification, and the steps of obtaining a configuration form through a preset configuration webpage and converting the configuration form into gateway parameters include:

[0027] If the permission verification request is detected, the identity number and password of the preset request network are verified through the identity verification plug-in in the API communication module.

[0028] In addition, to achieve the above-mentioned purpose, the present application also provides a gateway construction device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to execute the steps of the gateway construction method based on APISIX as described above.

[0029] In addition, to achieve the above-mentioned purpose, the present application also provides a storage medium, which is a computer-readable storage medium, and a program for implementing a gateway construction method based on APISIX is stored on the computer-readable storage medium. The program for implementing a gateway construction method based on APISIX is executed by a processor to implement the steps of the gateway construction method based on APISIX as described above.

[0030] The present application provides a gateway construction method based on APISIX, which obtains a configuration form through a preset configuration web page, and converts the configuration form to obtain gateway parameters; the etcd storage module is set through the gateway parameters to store routing information; the API communication module is set through the gateway parameters, and the Nginx collaboration module is set, and the gateway is completed. The Nginx collaboration module can collaborate with the API communication module to process requests of the preset request network based on the routing information.

[0031] In summary, this application sets up a configuration web page to visually represent the gateway parameters needed to build the gateway, allowing users to complete gateway construction without complex programming design, and enables users to adaptively modify the gateway according to the needs of their own service platform system, thereby lowering the technical threshold for gateway construction. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0033] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0034] Figure 1 A flowchart of the first embodiment of the method for constructing a gateway based on APISIX of this application is provided;

[0035] Figure 2 Flow chart of the second embodiment of the gateway construction method based on APISIX provided in this application

[0036] Figure 3 A brief flowchart of a gateway construction method based on APISIX provided in an embodiment of the present application;

[0037] Figure 4 A schematic diagram of the module structure of a gateway construction device according to an embodiment of the present application;

[0038] Figure 5 A schematic diagram of the device structure of the hardware operating environment involved in the APISIX-based gateway construction method provided in one embodiment of the present application.

[0039] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0040] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0041] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0042] The main solution of this application is: to obtain gateway parameters through a preset configuration web page; to set the etcd storage module through the gateway parameters to store routing information; to set the API communication module through the gateway parameters, and to set the Nginx collaboration module through the gateway parameters, and to collaborate with the API communication module through the Nginx collaboration module to obtain the routing information.

[0043] At present, dynamic routing configuration technology is usually used, such as dynamic routing based on Etcd, to update routing rules in real time without restarting the service or manually changing the configuration file. However, when configuring different service platform systems, the background program needs to be modified and designed, and the designer needs to have the ability to develop communication network technology. The technical threshold is relatively high. However, considering that the operators of the service platform system involve multiple industries such as online shopping, financial services, content hosting, social networks, and online games, the operators are not professionals in the field of communication network technology, and the gateway in the service platform system needs to be adjusted in parameters during the daily operation of the service platform system. How to enable people in different fields to build a gateway suitable for their own service platform system is a problem worthy of attention.

[0044] This application sets up a configuration web page to visually represent the gateway parameters needed to build the gateway, allowing users to complete gateway construction without complex programming design, and enables users to adaptively modify the gateway according to the needs of their own service platform system, thereby lowering the technical threshold for gateway construction.

[0045] It should be noted that the execution subject of this embodiment is a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or a gateway construction device capable of realizing the above functions, etc., and this embodiment does not specifically limit this. The following takes the gateway construction as the execution subject as an example to illustrate this embodiment and the following embodiments.

[0046] Based on this, this application proposes a gateway construction method based on APISIX in the first embodiment, please refer to Figure 1 The gateway includes an etcd storage module, an API communication module and an Nginx collaboration module. The gateway construction method based on APISIX includes steps S10 to S30:

[0047] Step S10, obtaining a configuration form through a preset configuration webpage, and converting the configuration form to obtain gateway parameters;

[0048] It should be noted that the etcd storage module refers to a module used to store routing information and other key configuration data. The API communication module refers to a module that provides an API interface and processes and manages received data through the API interface. The Nginx collaboration module refers to a module that works with the API communication module to improve data forwarding efficiency. The preset configuration webpage refers to a webpage for setting gateway parameters. Gateway parameters refer to the parameters required to configure the gateway.

[0049] It should also be noted that the configuration form refers to a text form that contains information for setting gateway parameters in a preset configuration web page.

[0050] In a feasible embodiment, the gateway parameters include authority verification, step S10, through a preset configuration webpage, after obtaining the gateway parameters, includes step S101:

[0051] Step S101, verifying the identity number and password of the preset request network through the identity authentication plug-in in the API communication module.

[0052] It should be noted that permission verification refers to verifying whether the gateway has permission to access the interface and address. Authentication plug-ins refer to functional plug-ins that implement permission verification functions, such as OpenID-Connect. Implanting the authentication plug-in into the API communication module can implement permission verification.

[0053] In a feasible embodiment, the API communication module is implemented using apisix, and the OpenID-Connect plug-in of apisix is ​​used as an identity authentication plug-in to achieve identity authentication and authorization, that is, identity identification is performed by verifying the client_id and client_secret in the user request, where the user request refers to the communication request sent by the preset request network, and client_id and client_secret refer to the identity number and password of the communication request sent by the preset request network.

[0054] This embodiment implements the permission verification function in the gateway parameters through the identity authentication plug-in, ensuring that each time the gateway constructed by the gateway construction method based on APISIX in this embodiment performs network communication, it is necessary to verify the request permission, thereby improving the security of the gateway construction method based on APISIX in this embodiment.

[0055] Step S20, setting the etcd storage module through gateway parameters to store routing information;

[0056] It should be noted that routing information refers to information used to guide the forwarding of data packets from one network node to the next node. This information defines the transmission path of the data packet from the source address to the destination address.

[0057] In this embodiment, the routing information includes the target network address, subnet mask, next hop address, egress interface, routing protocol and metric value, etc. In this embodiment, the routing information is mainly stored through Etcd.

[0058] In a feasible embodiment, the gateway parameters include a storage path, a communication port, and a communication protocol. Step S20, the step of setting the etcd storage module through the gateway parameters includes step S201:

[0059] Step S201, connect the API communication module and the etcd storage module through the communication port and the communication protocol, configure the etcd storage module through the storage path, and the etcd storage module stores the routing information according to the storage path.

[0060] It should be noted that the storage path refers to the path for storing routing information, which is used to find and save routing information. The communication port refers to the port identifier used to connect the API communication module and the etcd storage module. The communication protocol refers to the communication standard for realizing communication between the API communication module and the etcd storage module.

[0061] In this embodiment, after the gateway parameters are obtained, the gateway parameters need to be stored in the etcd storage module so that the gateway can subsequently obtain routing information from the etcd storage module.

[0062] It should be noted that, in this embodiment, the etcd storage module is initialized by the initial-cluster parameter to form an initial etcd cluster. In the etcd cluster, each etcd node specifies its own name through the name parameter, and sets the address and port for communication between etcd nodes through the listen-peer-urls parameter, and sets the address and port for client access through the listen-client-urls parameter. In the etcd storage module, the routing information and configuration data of each etcd node are stored in the data-dir directory.

[0063] This embodiment realizes the connection between the API communication module and the etcd storage module through three gateway parameters: storage path, communication port and communication protocol. Since the etcd storage module supports multi-data center deployment, the Paxos algorithm is used to ensure data consistency in the distributed system, thereby improving the performance of the gateway constructed by the gateway construction method based on APISIX in this embodiment.

[0064] Step S30, setting the API communication module through gateway parameters, and setting the Nginx collaboration module, the gateway is constructed, and the Nginx collaboration module can collaborate with the API communication module to process requests of the preset request network based on routing information.

[0065] It should be noted that the Nginx collaboration module is built by the Nginx server.

[0066] In a feasible embodiment, the configuration file of the API communication module includes, data-dir: specifies the path for etcd data storage. name: the name of each etcd node. initial-cluster: the list of nodes required to initialize the cluster, in the format of node name = node address. initial-cluster-token: the unique token used when the cluster is initialized. listen-peer-urls and listen-client-urls: listen to the URLs of other nodes and the URLs of the client. client-transport-security and peer-transport-security: used to configure etcd's secure transmission settings, including certificates, keys, and CA certificates.

[0067] In another feasible embodiment, the configuration file set by the etcd storage module includes identifying the initial-cluster: parameter to form a cluster at startup. All routing information and configuration data are stored in the data-dir directory. Each node specifies its own name through the name parameter, and sets the address and port for inter-node communication and client access through the listen-peer-urls and listen-client-urls parameters respectively.

[0068] It is understandable that the Nginx collaboration module can collaborate with the API communication module. The specific work of the collaboration includes setting the correct worker process, connection number limit, file opening limit, etc., and then processing the requests of the preset request network through collaboration to realize the gateway function.

[0069] In a feasible embodiment, the gateway parameters include a request address and a forwarding address. Step S30, the step of setting the API communication module through the gateway parameters also includes steps A10 to A20:

[0070] Step A10, obtaining routing information from the etcd storage module through the communication port and communication protocol;

[0071] It should be noted that the request address refers to the address of the preset request network that requests communication with the gateway, and the forwarding address refers to the address of the preset target network that requests communication with the preset request network.

[0072] It should be noted that the preset request network may be any gateway for making a communication request through the gateway constructed by this embodiment, and the preset target network is a network specified in the communication request that needs to communicate with the preset request network.

[0073] It is understandable that obtaining routing information requires a communication port and a communication protocol. A communication port is a virtual address in network communication used to identify different services running on the same host. For example, HTTP services usually use port 80 and HTTPS services use port 443.

[0074] Step A20, building a communication path between the request address and the forwarding address through routing information, completing the API communication module setting.

[0075] It can be understood that the request address and forwarding address are the parts that users need to modify when configuring the API communication module when building the gateway, and the rest is pre-implemented through programming. Users can modify the request address and forwarding address in the preset configuration web page.

[0076] This embodiment completes the configuration of the API communication module by setting the request address and forwarding address, and enables the constructed gateway to process requests from the preset request network. Users do not need to use cumbersome coding to implement this function, thereby reducing the technical threshold for gateway construction.

[0077] It should be noted that when this embodiment obtains routing information to complete the configuration of the API communication module, it is necessary to first obtain the client-transport-security parameters and the peer-transport-security parameters, configure the secure transmission settings of etcd, including certificates, keys, and CA certificates, etc. It is also necessary to determine the directory data-dir of the routing information in the etcd storage module, as well as the name parameters, listen-peer-urls parameters, and listen-client-urls parameters of the corresponding etcd node, as well as the initial-cluste parameters and initial-cluster-token parameters required for the initial etcd cluster (the only token used when the etcd cluster is initialized).

[0078] In another feasible embodiment, step S30 and the step of setting the Nginx collaboration module include steps B10 to B20:

[0079] Step B10, dynamically constructing Nginx collaborative module configuration through routing information, adding or updating location blocks and upstream definitions in the Nginx collaborative module configuration;

[0080] Step B20, setting the Nginx collaborative module through the Nginx collaborative module configuration.

[0081] It should be noted that the location block refers to one of the parameters configured by the Nginx collaborative module, which is used to define how to handle a specific URL path, and the upstream definition refers to one of the parameters configured by the Nginx collaborative module, which is used to define the server.

[0082] It can be understood that the specific work of collaboration includes setting the correct worker process, connection number limit, file opening limit, etc., and then processing the requests of the preset request network through collaboration to realize the function of the gateway.

[0083] Furthermore, the worker process setting refers to a process or thread responsible for executing a specific task in a multi-process or multi-thread environment. In this embodiment, the task of executing communication information forwarding is to forward information from a preset request network to a preset target network.

[0084] In a feasible embodiment, the collaboration between the Nginx collaboration module and the API communication module is achieved by configuring Nginx as a reverse proxy to forward requests from a preset request network to the API communication module for processing.

[0085] This embodiment is based on the gateway construction method of APISIX, and realizes the collaboration between the Nginx collaboration module and the API communication module through the worker process setting. Through the collaboration, the gateway forwards information from the preset request network to the preset target network, thereby improving the gateway performance and lowering the technical threshold for gateway construction.

[0086] In a feasible embodiment, step B20, after setting the Nginx collaboration module through the Nginx collaboration module configuration, further includes steps C10 to C20:

[0087] Step C10: If the routing information changes, the Nginx collaboration module configuration is hot updated through the virtual machine module to obtain the updated configuration and trigger script;

[0088] Step C20, using a trigger script to trigger the Nginx collaborative module to reload, and loading the updated configuration into the Nginx collaborative module update settings.

[0089] It should be noted that the virtual machine module refers to a module that completes the configuration update of the Nginx collaborative module through a virtual machine.

[0090] In a feasible embodiment, the virtual machine used by the virtual machine module is LuaJITVM, and OpenResty is composed of Nginx plus LuaJIT mode. OpenResty is a Web platform that allows Nginx to be used not only as a static content server and reverse proxy, but also as a full-featured Web application server. The hot update of the Nginx collaborative module configuration is realized through the ngx_http_lua_module in the virtual machine module, thereby obtaining the updated configuration, and the trigger script is constructed through the virtual machine module. The trigger script is composed of lua language, and the Nginx collaborative module is triggered by the trigger script to reload the configuration, and the updated configuration is loaded in the Nginx collaborative module to realize the dynamic construction of the Nginx collaborative module configuration file. This embodiment realizes the dynamic construction of the Nginx collaborative module configuration file through the ngx_http_lua_module of OpenResty, and triggers the Nginx collaborative module reload through the trigger script, without restarting the Nginx service, thereby improving the working performance of the Nginx collaborative module.

[0091] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the first embodiment can refer to the above introduction, and will not be repeated in the following. Figure 2 , the routing information includes routing rules, the gateway includes a timer module, the API communication module includes a routing table, the API communication module is set through the gateway parameters, and the Nginx collaboration module is set. After the gateway completes the construction steps, it includes:

[0092] Step S01, periodically query the routing information in the etcd storage module through the timer module;

[0093] Step S02: When the routing rules change, the API communication module updates the routing table.

[0094] It should be noted that routing information also includes routing rules, which refer to a set of instructions defined on the router to guide the forwarding of data packets. Routing protocols refer to protocols used to exchange routing information between network devices. They ensure that routers in the network can share and update routing information, thereby achieving effective forwarding of data packets. The timer module refers to the timer mechanism built into the gateway based on APISIX, which performs specific operations after a specific time interval. The routing table is used to determine which preset target network the request should be sent to.

[0095] In a feasible embodiment, APISIX is used to build a gateway. First, the information of the etch storage module (address, prefix information) is configured in the configuration file config.yaml of the API communication module. Routing rules are added or updated through the apisixdashboard. The routing rules will be stored in the etcd storage module.

[0096] A gateway is built based on APISIX, and the timer mechanism (ngx.timer.at) in APISIX is used to periodically query the routing information in the etcd storage module, thereby realizing the watch function of the etcd storage module. When the routing rules in etcd change, the gateway built based on APISIX in this embodiment can instantly obtain the changes and update its routing table.

[0097] This embodiment realizes real-time monitoring of data through the timer mechanism in APISIX. When the routing information changes, the update event is triggered through the watch mechanism, such as updating the Nginx collaborative module configuration, and the routing table is updated, thereby improving the response speed of the gateway. The watch function of the etcd storage module can be easily expanded, supports subscribing to multiple keys at the same time, and can share subscriptions between multiple clients (networks), so that the gateway constructed in this embodiment can flexibly manage complex routing information.

[0098] In a feasible embodiment, the gateway construction method based on APISIX further includes step D10:

[0099] Step D10, monitor the etcd storage module through the preset monitoring function, and when the routing information changes, execute the step of updating the routing table by the API communication module.

[0100] It should be noted that the preset monitoring function refers to a function used to monitor routing information changes in the Etcd storage module.

[0101] It is understandable that in software development, preset monitoring functions usually refer to functions that are defined in the design phase and are used to handle specific events. These functions are usually pre-written in the code and are automatically called when an event occurs.

[0102] In a feasible embodiment, the gateway built based on APISIX in this embodiment uses the lua-resty-etcd library (OpenResty) to interact with the etcd storage module. When the etcd storage module changes, APISIX monitors the change event through the watchdir function of the lua-resty-etcd library and performs corresponding processing (updates the Nginx collaborative module configuration, etc.).

[0103] The gateway constructed by the gateway construction method based on APISIX in this embodiment can efficiently monitor changes in routing information in the etcd storage module and update its routing rules in a timely manner to ensure that the gateway's routing decisions are always up to date. Even if the backend service changes, the gateway can quickly adjust the routing strategy, thereby maintaining the continuity and reliability of the gateway communication service.

[0104] For example, in order to help understand the technical concept or technical principle of the gateway construction method based on APISIX in this embodiment and the above-mentioned embodiment 1, please refer to Figure 3 , Figure 3 A brief flowchart of the gateway construction method based on APISIX is provided, as follows:

[0105] 1. Deploy and configure the Etcd cluster to store Apisix routing information, set up a suitable data-dir to store data, and configure the ports and protocols for communication between nodes.

[0106] 2. Install Apisix and configure it to communicate with the Etcd cluster so that routing information can be loaded from Etcd. It can be built based on OpenResty (Nginx+LuaJIT). The goal of Openresty is to allow users' Web services to run directly inside the Nginx service, making full use of Nginx's non-blocking I / O model, and providing high-performance support not only for HTTP client requests, but also for back-end proprietary protocol requests such as MySQL, PostgreSQL, Memcached, and Redis. Openresty has introduced many hook points by fully extending Nginx, and these hooks can be implemented using the Lua language to expand functions.

[0107] 3. Configure Nginx to work with Apisix, including setting the correct worker process, connection limit, file opening limit and other configuration items.

[0108] 4. Dynamic synchronization of routing information is achieved through code logic, so that Apisix can read routing information from Etcd and dynamically build the Nginx configuration file nginx.conf.

[0109] Among them, Etcd cluster is etcd storage module, Apisix is ​​API communication module, Nginx is Nginx collaboration module, and configuration file nginx.conf is dynamic configuration file.

[0110] Furthermore, taking routing as an example, Nginx needs to be configured in the configuration file, and each change needs to be reloaded before it can take effect. In order to realize dynamic routing configuration, Apache APISIX configures a single server in the NGINX configuration file, and this server has a location. We use this location as the main entry point, and all requests will pass through this location, and then APISIX Core will dynamically specify the specific upstream. Therefore, the routing module of Apisix supports adding, subtracting, modifying and deleting routes at runtime, realizing dynamic loading, and all these changes are zero-perception to the client. For example, to add a reverse proxy for a new domain name, you only need to create an upstream and add a new route in Apisix, and the Nginx process does not need to be restarted during the whole process. For example, in the plug-in system, Apisix can implement the IP blacklist and whitelist function through the ip-restriction plug-in. The update of these capabilities is also dynamic, and there is no need to restart the service. With the help of etcd configuration centralized storage, the configuration policy is pushed in real time in an incremental manner, and finally all rules are effective in real time and dynamically, bringing a good experience to users.

[0111] It should be noted that the above examples are only used to assist in understanding the present application and do not constitute a limitation on the gateway construction method based on APISIX of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0112] The present application also provides a gateway construction device, please refer to Figure 4 , the gateway construction device comprises:

[0113] The parameter configuration module 10 is used to obtain gateway parameters through the configuration web page;

[0114] The routing storage module 20 is used to set the etcd storage module through the gateway parameters and store routing information;

[0115] The routing acquisition module 30 is used to set the API communication module through the gateway parameters, and to set the Nginx collaboration module through the gateway parameters, and to collaborate with the API communication module through the Nginx collaboration module to acquire the routing information.

[0116] Optionally, the gateway parameters include a storage path, a communication port and a communication protocol, and the routing storage module 20 is further used for:

[0117] The API communication module and the etcd storage module are connected through the communication port and the communication protocol, the etcd storage module is configured through the storage path, and the etcd storage module stores the routing information according to the storage path.

[0118] Optionally, the gateway parameters include a request address and a forwarding address, and the route acquisition module 30 is further used to:

[0119] Obtain the routing information from the etcd storage module through the communication port and communication protocol;

[0120] A communication path is constructed between the request address and the forwarding address through the routing information, and the API communication module setting is completed.

[0121] Optionally, the route acquisition module 30 is further used for:

[0122] Dynamically constructing an Nginx collaborative module configuration through the routing information, adding or updating a location block and an upstream definition in the Nginx collaborative module configuration;

[0123] The Nginx collaborative module is set through the Nginx collaborative module configuration.

[0124] Optionally, the gateway includes a virtual machine module, and the route acquisition module 30 of the gateway construction device is further used for:

[0125] If the routing information changes, the Nginx collaboration module configuration is hot updated through the virtual machine module to obtain the updated configuration and trigger script;

[0126] The trigger script is used to trigger the Nginx collaborative module to reload, and the update configuration is loaded into the Nginx collaborative module update setting.

[0127] Optionally, the routing information includes routing rules, the gateway includes a timer module, the API communication module includes a routing table, and the routing storage module 20 is further used to:

[0128] The routing information in the etcd storage module is periodically queried through the timer module;

[0129] When the routing rule changes, the API communication module updates the routing table.

[0130] Optionally, the gateway construction device is further used for:

[0131] The etcd storage module is monitored through a preset monitoring function, and when the routing information changes, the API communication module is executed to update the routing table.

[0132] Optionally, the gateway construction device is further used for:

[0133] The account and password of the preset request network are verified through the identity authentication plug-in in the API communication module.

[0134] The gateway construction device provided in the embodiment of the present application adopts the gateway construction method based on APISIX in the above embodiment, which can solve the technical problem of how to quickly adjust gateway parameters according to business scenarios and realize high-availability configuration and high-performance forwarding of gateways. Compared with the prior art, the beneficial effects of the gateway construction device provided in the embodiment of the present application are the same as the beneficial effects of the gateway construction method based on APISIX provided in the above embodiment, and the other technical features in the gateway construction device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0135] The present application provides a gateway construction device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the APISIX-based gateway construction method in the above-mentioned embodiment 1.

[0136] Reference below Figure 5 , which shows a schematic diagram of the structure of a gateway construction device suitable for implementing the embodiment of the present application. The gateway construction device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The gateway construction device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0137] like Figure 5As shown, the gateway construction device may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the gateway construction device are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the gateway construction device to communicate with other devices wirelessly or wired to exchange data. Although the figure shows a gateway construction device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0138] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0139] The gateway construction device provided by this application adopts the gateway construction method based on APISIX in the above embodiment, which can solve the technical problem of how to quickly adjust gateway parameters according to business scenarios and realize high-availability configuration and high-performance forwarding of gateways. Compared with the prior art, the beneficial effects of the gateway construction device provided by this application are the same as the beneficial effects of the gateway construction method based on APISIX provided in the above embodiment, and the other technical features in the gateway construction device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0140] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0141] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0142] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the APISIX-based gateway construction method in the above-mentioned embodiment.

[0143] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0144] The computer-readable storage medium may be included in the gateway construction device; or may exist independently without being assembled into the gateway construction device.

[0145] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the gateway construction device, the gateway construction device: obtains the configuration form through the preset configuration web page, and converts the configuration form to obtain gateway parameters; sets the etcd storage module through the gateway parameters to store routing information; sets the API communication module through the gateway parameters, and sets the Nginx collaboration module, and the gateway is completed. The Nginx collaboration module can collaborate with the API communication module to process requests for the preset request network based on the routing information.

[0146] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0147] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0148] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0149] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned gateway construction method based on APISIX, and can solve the technical problem of how to quickly adjust gateway parameters according to business scenarios and achieve high-availability configuration and high-performance forwarding of gateways. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the gateway construction method based on APISIX provided in the above-mentioned embodiment, which will not be repeated here.

[0150] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.

Claims

1. A gateway construction method based on APISIX, characterized in that: The gateway includes an etcd storage module, an API communication module, and an Nginx collaboration module. The gateway construction method based on APISIX includes: Obtain a configuration form through a preset configuration webpage, and convert the configuration form to obtain gateway parameters; The etcd storage module is set through the gateway parameters to store routing information; The API communication module is set through the gateway parameters, and the Nginx collaboration module is set, and the gateway is constructed. The Nginx collaboration module can collaborate with the API communication module to process requests for the preset request network based on the routing information.

2. The method according to claim 1, characterized in that The gateway parameters include a storage path, a communication port, and a communication protocol. The step of setting the etcd storage module through the gateway parameters includes: The API communication module and the etcd storage module are connected through the communication port and the communication protocol, the etcd storage module is configured through the storage path, and the etcd storage module stores the routing information according to the storage path.

3. The method according to claim 2, characterized in that The gateway parameters include a request address and a forwarding address, and the step of setting the API communication module through the gateway parameters includes: Obtain the routing information from the etcd storage module through the communication port and communication protocol; A communication path is constructed between the request address and the forwarding address through the routing information, and the API communication module setting is completed.

4. The method according to claim 1, characterized in that The step of setting the Nginx collaborative module includes: Dynamically constructing an Nginx collaborative module configuration through the routing information, adding or updating a location block and an upstream definition in the Nginx collaborative module configuration; The Nginx collaborative module is set through the Nginx collaborative module configuration.

5. The method according to claim 4, characterized in that The gateway includes a virtual machine module, and the step of configuring the Nginx collaborative module through the Nginx collaborative module further includes: If the routing information changes, the Nginx collaboration module configuration is hot updated through the virtual machine module to obtain the updated configuration and trigger script; The trigger script is used to trigger the Nginx collaborative module to reload, and the update configuration is loaded into the Nginx collaborative module update setting.

6. The method according to claim 1, characterized in that The routing information includes routing rules, the gateway includes a timer module, the API communication module includes a routing table, the API communication module is set by the gateway parameters, and the Nginx collaboration module is set. After the gateway completes the construction steps, the steps include: The routing information in the etcd storage module is periodically queried through the timer module; When the routing rule changes, the API communication module updates the routing table.

7. The method according to claim 6, characterized in that The method further comprises: The etcd storage module is monitored through a preset monitoring function, and when the routing information changes, the API communication module is executed to update the routing table.

8. The method according to claim 1, characterized in that The gateway parameters include authority verification, and the steps of obtaining a configuration form through a preset configuration webpage and converting the configuration form into gateway parameters include: The identity number and password of the preset request network are verified through the identity authentication plug-in in the API communication module.

9. A gateway construction device, characterized in that: The gateway construction device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the APISIX-based gateway construction method as described in any one of claims 1 to 8.

10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the APISIX-based gateway construction method as described in any one of claims 1 to 8 are implemented.