Nginx request data collection method and device, equipment and storage medium

By loading a probe tool when the Nginx application starts to identify and collect request data, the problems of inconvenient operation and maintenance and limited data collection in the existing technology are solved, and the automated deployment and rich collection of Nginx request data are realized.

CN115269055BActive Publication Date: 2026-02-10BONREE DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210956142.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-10
Publication Date
2026-02-10
Estimated Expiration
2042-08-10

AI Technical Summary

Technical Problem

Existing technologies for monitoring Nginx request data present challenges in terms of operational inconvenience and limitations on the types of data collected. This is especially true when Nginx does not include a status monitoring module or when log monitoring metrics need to be manually configured, which can easily lead to errors.

Method used

The probe tool identifies the Nginx application when the application starts, loads the Nginx probe, listens for business requests and collects the first request data. After forwarding to the backend server, it collects the second request data and combines the two as the target request data.

Benefits of technology

It enables automated deployment of Nginx data requests, improves the diversity, richness and convenience of data collection, and simplifies the operation and maintenance process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115269055B_ABST
    Figure CN115269055B_ABST
Patent Text Reader

Abstract

The application discloses an Nginx request data collection method and device, equipment and a storage medium. The method comprises the following steps: in the application program starting process, the program identification module in the probe tool is used for program identification on the application program; if the application program is identified as an Nginx application program, the program identification module is used for determining and loading the Nginx probe corresponding to the Nginx application program; the Nginx probe is used for listening to the service request received by the Nginx application program and collecting the first request data of the service request; when the Nginx application program is executed as a reverse proxy server function, the second request data of the service request is collected by the Nginx probe after the service request is forwarded to the back-end server; and the first request data and the second request data are used as the target request data of the execution process of the Nginx application program. The application embodiment improves the richness and convenience of collecting Nginx request data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to an Nginx request data collection method, apparatus, device, and storage medium. Background Technology

[0002] Nginx (engine x) is a lightweight web server and reverse proxy server. Due to its small memory footprint, fast startup speed, and strong concurrency capabilities, it is widely used in Internet projects.

[0003] Traditional methods for monitoring Nginx's business request collection fall into two categories: The first is using Nginx's status monitoring module to monitor Nginx data; the second is collecting Nginx logs for monitoring. However, for the first method, if the deployed Nginx does not include a status monitoring module, it needs to be recompiled, which is inconvenient for operation and maintenance, and limits the types of request performance metrics that can be collected. For the second method, it is necessary to manually configure the metrics to be monitored for Nginx, and then collect the data from the log files of the log monitoring system, which is inconvenient for operation and maintenance and prone to errors. Summary of the Invention

[0004] This invention provides a method, apparatus, device, and storage medium for collecting Nginx request data, in order to improve the richness and convenience of collecting Nginx request data.

[0005] According to one aspect of the present invention, an Nginx request data collection method is provided, the method comprising:

[0006] During the application startup process, the application is identified using the program identification module in the probe tool;

[0007] If the application is identified as an Nginx application, the Nginx probe corresponding to the Nginx application is determined and loaded through the application identification module.

[0008] The Nginx probe listens for business requests received by the Nginx application and collects the first request data of the business requests.

[0009] When the Nginx application is executed as a reverse proxy service, after forwarding the business request to the backend server, the second request data of the business request is collected through the Nginx probe.

[0010] The first request data and the second request data are used as the target request data for the Nginx application execution process.

[0011] According to another aspect of the present invention, an Nginx request data collection device is provided, the device comprising:

[0012] The application identification module is used to identify the application during the application startup process by using the application identification module in the probe tool.

[0013] The Nginx probe determination module is used to determine and load the Nginx probe corresponding to the Nginx application through the program identification module if the application is identified as an Nginx application.

[0014] The first request data collection module is used to listen to the business requests received by the Nginx application through the Nginx probe, and collect the first request data of the business requests.

[0015] The second request data collection module is used to collect the second request data of the business request through the Nginx probe after the business request is forwarded to the backend server when the Nginx application is executed as a reverse proxy service.

[0016] The target request data determination module is used to use the first request data and the second request data as the target request data for the execution process of the Nginx application.

[0017] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0018] At least one processor; and

[0019] A memory communicatively connected to the at least one processor; wherein,

[0020] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the Nginx request data collection method according to any embodiment of the present invention.

[0021] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the Nginx request data acquisition method according to any embodiment of the present invention.

[0022] This invention, in its embodiments, identifies the application during its startup process using a program identification module within a probe tool. Upon identifying an Nginx application, it loads the corresponding Nginx probe. The Nginx probe then listens for business requests received by the Nginx application and collects first and second request data to determine the target request data during the Nginx application's execution. This solution automates the deployment of the Nginx probe used for collecting Nginx request data. The deployment method is simple, and it can acquire rich Nginx request data as needed, improving the diversity, richness, and convenience of Nginx request data collection.

[0023] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0024] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0025] Figure 1 This is a flowchart of an Nginx request data collection method according to Embodiment 1 of the present invention;

[0026] Figure 2 This is a flowchart of an Nginx request data collection method according to Embodiment 2 of the present invention;

[0027] Figure 3 This is a flowchart of an Nginx request data collection method according to Embodiment 3 of the present invention;

[0028] Figure 4 This is a schematic diagram of the structure of an Nginx request data acquisition device according to Embodiment 4 of the present invention;

[0029] Figure 5 This is a schematic diagram of the structure of an electronic device that implements the Nginx request data collection method according to an embodiment of the present invention. Detailed Implementation

[0030] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0031] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0032] Example 1

[0033] Figure 1 This invention provides a flowchart of an Nginx request data collection method according to Embodiment 1. This embodiment is applicable to the collection of Nginx request data. The method can be executed by an Nginx request data collection device, which can be implemented in hardware and / or software and can be configured in an electronic device. Figure 1 As shown, it includes:

[0034] S110. During the application startup process, the application is identified through the program identification module in the probe tool.

[0035] The application can be any program running on the system. For example, an application can be an Nginx application, that is, an application running in the Nginx proxy server.

[0036] The probe tool can be a device, program, or process used to deploy probes within the system. For example, the probe tool could be SmartAgent. The application identification module can be a module used to monitor and identify applications; it can be deployed within the probe tool or within the system. For example, if the probe tool is SmartAgent, the application identification module could be Agentloader.

[0037] For example, if the probe tool is SmartAgent and the program identification module is Agentloader, then SmartAgent can be deployed in the running system to which the application belongs. Through Agentloader in SmartAgent, the system's applications can be monitored, and when an application is detected to be starting, the application can be identified.

[0038] S120. If the application is identified as an Nginx application, the Nginx probe corresponding to the Nginx application is determined and loaded through the program identification module.

[0039] Among them, Nginx probes can be used to collect business requests from Nginx applications and obtain performance data or metric data related to those business requests.

[0040] Different applications can correspond to different probes, which can be pre-configured by relevant technical personnel according to actual needs. For example, the probe corresponding to the Nginx application can be the Nginx probe.

[0041] For example, if the program identification module identifies the application being started as an Nginx application, the program identification module determines the Nginx probe corresponding to the Nginx application and loads the determined Nginx probe.

[0042] Optionally, if the probe tool is SmartAgent and the program identification module is Agentloader, then Agentloader can determine that the probe corresponding to the Nginx application is NignxAgent, and load the determined NignxAgent.

[0043] S130. Use the Nginx probe to listen for business requests received by the Nginx application and collect the first request data of the business requests.

[0044] In this context, a business request can be any request sent by the business initiator through the Nginx proxy server.

[0045] The first request data may include at least one of the following: request method, request link, request header, request start time, request address, request end time, and request response code.

[0046] For example, an Nginx probe can be used to listen for at least one business request received by an Nginx application; when a business request is detected, the first request data corresponding to the business request can be collected.

[0047] S140. When the Nginx application is executed as a reverse proxy service, after forwarding the business request to the backend server, the second request data of the business request is collected through the Nginx probe.

[0048] The Nginx application sends the obtained business requests to the backend server. During the process of the Nginx application sending the business requests to the backend server, some of the request data corresponding to the business requests may change, such as the request link, i.e., the request URL (Uniform Resource Locator).

[0049] The second request data may include at least one of the following: calling protocol, request link, and request start time.

[0050] For example, when the Nginx probe detects that the Nginx application is being executed as a reverse proxy service, and forwards the business request to the backend server, the Nginx probe collects the second request data corresponding to the business request sent to the backend server.

[0051] S150. Use the first request data and the second request data as the target request data for the Nginx application execution process.

[0052] For example, the collected first request data and second request data can be used as the target request data in the Nginx application execution process for subsequent data analysis and visualization of the Nginx target request data.

[0053] This invention, in its embodiments, identifies the application during its startup process using a program identification module within a probe tool. Upon identifying an Nginx application, it loads the corresponding Nginx probe. The Nginx probe then listens for business requests received by the Nginx application and collects first and second request data to determine the target request data during the Nginx application's execution. This solution automates the deployment of the Nginx probe used for collecting Nginx request data. The deployment method is simple, and it can acquire rich Nginx request data as needed, improving the diversity, richness, and convenience of Nginx request data collection.

[0054] Example 2

[0055] Figure 2 This is a flowchart of an Nginx request data collection method provided in Embodiment 2 of the present invention. This embodiment is an optimization and improvement based on the above technical solutions.

[0056] Furthermore, the step "If the application is identified as an Nginx application, then determine the Nginx probe corresponding to the Nginx application through the application identification module" is refined to "If the application is identified as an Nginx application, then create a temporary Nginx application configuration file through the application identification module; obtain the application configuration file of the Nginx application, and copy the original data in the application configuration file to the temporary Nginx application configuration file; add module loading instructions to the temporary Nginx application configuration file to obtain the Nginx application target file; determine and load the Nginx probe corresponding to the Nginx application through the module loading instructions in the Nginx application target file." This improves the method for determining the Nginx probe.

[0057] like Figure 2 As shown, the method includes the following specific steps:

[0058] S210. During the application startup process, the application is identified through the program identification module in the probe tool.

[0059] S220. If the application is identified as an Nginx application, a temporary configuration file for the Nginx application is created through the program identification module.

[0060] The Nginx application temporary configuration file is used to store relevant content from the main Nginx application and to add configuration information for subsequent Nginx probe acquisition. This temporary configuration file can be an `nginx.conf` file.

[0061] For example, if the application identified by the application identification module is an Nginx application, the application identification module can create a temporary configuration file nginx.conf for the Nginx application; if the application identified by the application identification module is an application other than the Nginx application, the application identification module can determine and load the probes corresponding to the other applications.

[0062] S230. Obtain the application configuration file of the Nginx application and copy the raw data in the application configuration file to the temporary configuration file of the Nginx application.

[0063] The application configuration file can be the main program file of the Nginx application. The raw program can be the content of the file in the application configuration file.

[0064] For example, the application configuration file of the Nginx application can be obtained through the program identification module, and the original data in the application configuration file can be copied to the temporary configuration file of the Nginx application.

[0065] S240. Add a module loading directive to the Nginx application's temporary configuration file to obtain the Nginx application target file.

[0066] Module loading directives can be used to load response modules. For example, a module loading directive added to the Nginx application's temporary configuration file could be used to load the Nginx probe module.

[0067] For example, the file containing the module loading directive will be added to the temporary configuration file of the Nginx application and used as the target file of the Nginx application.

[0068] S250. Determine and load the Nginx probe corresponding to the Nginx application by using the module loading instructions in the Nginx application target file.

[0069] It should be noted that during the process of identifying and loading the Nginx probe corresponding to the Nginx application, there may be a situation where the versions of the Nginx application and the Nginx probe are inconsistent, which may cause the loading of the Nginx probe to fail.

[0070] In an optional embodiment, the Nginx probe corresponding to the Nginx application is determined and loaded using the module loading instructions in the Nginx application target file. This includes: determining the probe to be loaded corresponding to the Nginx application using the module loading instructions in the Nginx application target file; determining whether the version information of the Nginx application is consistent with the version information of the probe to be loaded using the module loading instructions; if so, the probe to be loaded is used as the Nginx probe.

[0071] The probe to be loaded can be any version of the Nginx probe determined by the module loading instructions. The version information can include the Nginx application's version number and compilation signature.

[0072] For example, the module loading instruction can determine whether the version information of the Nginx application matches the version information of the probe to be loaded. Specifically, the module loading instruction can parse the Nginx application's main program file using ELF in the relevant parsing function, and obtain the Nginx application's version number information and compilation signature from the symbol table. If the version information of the Nginx application matches the version information of the probe to be loaded, the probe to be loaded is used as the Nginx probe.

[0073] In an optional embodiment, after determining whether the version information of the Nginx application is consistent with the version information of the probe to be loaded through the module loading instruction, the method further includes: if the version information of the Nginx application is inconsistent with the version information of the probe to be loaded, then using the version information of the Nginx application to update the version information of the probe to be loaded; and using the updated probe to be loaded as the Nginx probe.

[0074] For example, if the version information of the Nginx application is inconsistent with the version information of the probe to be loaded, the version information of the Nginx application is used to update the version information of the probe to be loaded; the updated probe to be loaded is then used as the Nginx probe. Specifically, the module loading instruction can obtain the version number information and compilation signature of the Nginx application from the symbol table, update the module to be loaded, and thus obtain the Nginx probe, ensuring that the Nginx probe and the Nginx application version are consistent.

[0075] This optional embodiment ensures that the version information of the Nginx application is consistent with the version information of the probe to be loaded by using module loading instructions. This achieves consistency between the Nginx probe and the Nginx application versions, avoiding the possibility of Nginx probe loading failure due to version inconsistencies between the Nginx application and the Nginx probe.

[0076] S260. Use the Nginx probe to listen for business requests received by the Nginx application and collect the first request data of the business requests.

[0077] S270. When the Nginx application is executed as a reverse proxy service, after forwarding the business request to the backend server, the second request data of the business request is collected through the Nginx probe.

[0078] S280. Use the first request data and the second request data as the target request data for the Nginx application execution process.

[0079] This invention's solution, upon identifying an application as an Nginx application, creates a temporary Nginx application configuration file using a program identification module; obtains the Nginx application's configuration file and copies its original data to the temporary Nginx application configuration file; adds a module loading instruction to the temporary Nginx application configuration file to obtain the Nginx application target file; and uses the module loading instruction in the Nginx application target file to determine and load the Nginx probe corresponding to the Nginx application. This solution improves the method of obtaining Nginx probes, achieving automated injection of Nginx probes and facilitating subsequent acquisition of Nginx application-related request data through Nginx probes.

[0080] Example 3

[0081] Figure 3 This is a flowchart of an Nginx request data collection method provided in Embodiment 3 of the present invention. This embodiment is an optimization and improvement based on the above technical solutions.

[0082] Furthermore, the first request data includes at least one of the following: request method, request link, request header, request start time, and request address. Correspondingly, the step "listening to business requests received by the Nginx application through an Nginx probe and collecting the first request data of the business requests" is refined to "deploying a request callback function during the rewrite phase of the Nginx application execution phase using an Nginx probe; listening to business requests received by the Nginx application through the request callback function; and collecting the first request data of the business requests based on the data structure of the Nginx framework corresponding to the Nginx application through the request callback function," thus improving the method for collecting the first request data.

[0083] Furthermore, the step "When the Nginx application is executed as a reverse proxy service, after forwarding the business request to the backend server, collect the second request data of the business request through the Nginx probe" is refined to "When the Nginx application is executed as a reverse proxy service, after forwarding the business request to the backend server, identify the backend call instruction of the backend server through the Nginx probe; collect the second request data of the business request according to the call method corresponding to the backend call instruction; wherein, the second request data includes the call protocol, request link, and request start time." This improves the method for collecting the second request data.

[0084] like Figure 3 As shown, the method includes the following specific steps:

[0085] S310. During the application startup process, the application is identified through the program identification module in the probe tool.

[0086] S320. If the application is identified as an Nginx application, the Nginx probe corresponding to the Nginx application is determined and loaded through the program identification module.

[0087] S330. Deploy request callback functions during the rewrite phase of Nginx application execution using Nginx probes.

[0088] It's important to note that Nginx applications divide request processing into 11 stages. Nginx probes can intervene in any stage to perform custom operations on request data processing. These Nginx application execution stages can include the rewrite stage.

[0089] Request callback functions are used to monitor business requests. For example, an Nginx probe can deploy request callback functions during the rewrite phase of an Nginx application's execution to monitor all business requests received by the Nginx application. For instance, an Nginx probe can register the NGX_HTTP_REWRITE_PHASE callback to monitor all business requests received by the Nginx application.

[0090] S340. Listen for business requests received by the Nginx application through a request callback function.

[0091] For example, you can listen for business requests received by the Nginx application through request callback functions registered during the rewrite phase using an Nginx probe.

[0092] S350. By using the request callback function, based on the data structure of the Nginx framework corresponding to the Nginx application, the first request data of the business request is collected.

[0093] The first request data includes at least one of the following: request method, request link, request headers, request start time, and request address. The request link can be a request URL.

[0094] For example, the request method, request link, and request address can be obtained through the request callback function based on the Nginx variable mechanism; and the request header can be collected by parsing the Nginx framework data structure.

[0095] In an optional embodiment, the first request data further includes the request end time and the request response code; correspondingly, the Nginx probe listens for business requests received by the Nginx application and collects the first request data of the business requests, including: deploying a request callback function in the logging phase of the Nginx application execution phase using the Nginx probe; and listening for the request end time and the request response code of the business requests using the request callback function.

[0096] The Nginx application execution phase may include a logging phase, which is used to log Nginx applications.

[0097] The request callback function is used to monitor the end time and response code of business requests. For example, an Nginx probe can deploy the request callback function during the logging phase of the Nginx application execution to monitor the start time and response code of all business requests received by the Nginx application. For instance, the Nginx probe can register the NGX_HTTP_LOG_PHASE callback to monitor the end time and response code of all business requests received by the Nginx application.

[0098] For example, the request duration of a business request can be determined by the request start time and request end time. Specifically, the request duration can be compared with a preset duration threshold to determine the request type. Request types include healthy requests, slow requests, and stalled requests. The duration threshold can be preset by relevant technical personnel according to actual needs. Different duration thresholds can be set for different request types.

[0099] For example, the validity of a business request can be determined by the obtained request response code. For instance, if the request response code is 4xx or 5xx, the business request can be considered an error.

[0100] S360: When the Nginx application is executed as a reverse proxy service, after forwarding business requests to the backend server, the backend call instructions of the backend server are identified through the Nginx probe.

[0101] The backend invocation instructions may include the `proxy_pass` instruction for capturing HTTP requests and the `fastcgi_pass` instruction for capturing socket requests. The backend server may be a server used to process business requests.

[0102] For example, when the Nginx application is executed as a reverse proxy service, after forwarding business requests to the backend server, the backend call instructions of the backend server can be identified through Nginx probes.

[0103] S370. Collect the second request data of the business request according to the calling method corresponding to the backend calling instruction; wherein, the second request data includes the calling protocol, the request link and the request start time.

[0104] For example, an Nginx probe can be used to determine the calling method corresponding to a backend call command, and based on that calling method, the calling protocol, request start time, and request response code of the business request can be collected. The request start time can be the time when the business request is sent to the business backend. The request response code can be the response code generated during the processing of the business request on the backend server.

[0105] For example, the request duration of a business request can be determined by the request start time and request end time. Specifically, the request duration can be compared with a preset duration threshold to determine the request type. Request types include healthy requests, slow requests, and stalled requests. The duration threshold can be preset by relevant technical personnel according to actual needs. Different duration thresholds can be set for different request types.

[0106] For example, the validity of a business request can be determined by the obtained request response code. For instance, if the request response code is 4xx or 5xx, the business request can be considered an error.

[0107] S380. Use the first request data and the second request data as the target request data for the Nginx application execution process.

[0108] This embodiment utilizes an Nginx probe to deploy request callback functions during the rewrite phase of the Nginx application execution. These callback functions monitor business requests received by the Nginx application. Based on the data structure of the Nginx framework corresponding to the Nginx application, the first request data of the business request is collected, thus achieving the collection of this first request data from the Nginx application. When the Nginx application is executed as a reverse proxy service, forwarding the business request to the backend server, the Nginx probe identifies the backend server's backend call instructions. Based on the call method corresponding to the backend call instructions, the second request data of the business request is collected. This achieves automated collection of request data throughout the entire execution process, improving the diversity, richness, and convenience of collecting Nginx request data.

[0109] Example 4

[0110] Figure 4 This is a schematic diagram of an Nginx request data acquisition device provided in Embodiment 4 of the present invention. The Nginx request data acquisition device provided in this embodiment of the present invention is applicable to the collection of Nginx request data. This Nginx request data acquisition device can be implemented in hardware and / or software, such as... Figure 4 As shown, the device specifically includes: a program identification module 401, an Nginx probe determination module 402, a first request data acquisition module 403, a second request data acquisition module 404, and a target request data determination module 405. Among them,

[0111] The program identification module 401 is used to identify the application during the application startup process by using the program identification module in the probe tool.

[0112] The Nginx probe determination module 402 is used to determine and load the Nginx probe corresponding to the Nginx application through the program identification module if the application is identified as an Nginx application.

[0113] The first request data acquisition module 403 is used to listen to the business requests received by the Nginx application through the Nginx probe and acquire the first request data of the business requests.

[0114] The second request data collection module 404 is used to collect the second request data of the business request through the Nginx probe after the business request is forwarded to the backend server when the Nginx application is executed as a reverse proxy service.

[0115] The target request data determination module 405 is used to use the first request data and the second request data as the target request data for the Nginx application execution process.

[0116] This invention, in its embodiments, identifies the application during its startup process using a program identification module within a probe tool. Upon identifying an Nginx application, it loads the corresponding Nginx probe. The Nginx probe then listens for business requests received by the Nginx application and collects first and second request data to determine the target request data during the Nginx application's execution. This solution automates the deployment of the Nginx probe used for collecting Nginx request data. The deployment method is simple, and it can acquire rich Nginx request data as needed, improving the diversity, richness, and convenience of Nginx request data collection.

[0117] Optionally, the Nginx probe determination module 402 includes:

[0118] The temporary configuration file creation unit is used to create a temporary Nginx application configuration file through the program identification module if the application is identified as an Nginx application.

[0119] The configuration file acquisition unit is used to acquire the application configuration file of the Nginx application and copy the original data in the application configuration file to the temporary configuration file of the Nginx application.

[0120] The target file acquisition unit is used to add module loading instructions to the Nginx application temporary configuration file to obtain the Nginx application target file;

[0121] The Nginx probe determination unit is used to determine and load the Nginx probe corresponding to the Nginx application by means of the module loading instructions in the Nginx application target file.

[0122] Optionally, the Nginx probe determination unit includes:

[0123] The probe to be loaded determination subunit is used to determine the probe to be loaded corresponding to the Nginx application through the module loading instructions in the Nginx application target file;

[0124] The version information determination subunit is used to determine whether the version information of the Nginx application is consistent with the version information of the probe to be loaded by the module loading instruction.

[0125] The Nginx probe determination subunit is used to determine if the version information of the Nginx application matches the version information of the probe to be loaded, and then uses the probe to be loaded as the Nginx probe.

[0126] Optionally, the Nginx probe determination unit further includes:

[0127] The version information update subunit is used to update the version information of the probe to be loaded by using the version information of the Nginx application after determining whether the version information of the Nginx application is consistent with the version information of the probe to be loaded through the module loading instruction. If the version information of the Nginx application is inconsistent with the version information of the probe to be loaded, the version information of the Nginx application is used to update the version information of the probe to be loaded.

[0128] The Nginx probe update subunit is used to use the updated probe to be loaded as the Nginx probe.

[0129] Optionally, the first request data includes at least one of the following: request method, request link, request header, request start time, and request address;

[0130] Accordingly, the first request data acquisition module 403 includes:

[0131] The first callback function deployment unit is used to deploy a request callback function during the rewrite phase of the Nginx application execution phase through the Nginx probe.

[0132] The business request listening unit is used to listen for business requests received by the Nginx application through the request callback function;

[0133] The first request data collection unit collects the first request data of the business request through the request callback function, based on the data structure of the Nginx framework corresponding to the Nginx application.

[0134] Optionally, the first request data may also include the request end time and the request response code;

[0135] Accordingly, the first request data acquisition module 403 includes:

[0136] The second callback function deployment unit is used to deploy request callback functions during the logging phase of the Nginx application execution phase through the Nginx probe.

[0137] The request response code monitoring unit is used to monitor the request end time and the request response code of the business request through the request callback function.

[0138] Optionally, the second request data acquisition module 404 includes:

[0139] The call instruction identification unit is used to identify the backend call instructions of the backend server through the Nginx probe after the business request is forwarded to the backend server when the Nginx application is executed as a reverse proxy service function.

[0140] The second request data collection unit is used to collect the second request data of the business request according to the calling method corresponding to the backend calling instruction;

[0141] The second request data includes the calling protocol, the request link, and the request start time.

[0142] The Nginx request data acquisition device provided in this embodiment of the invention can execute the Nginx request data acquisition method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method execution.

[0143] Example 5

[0144] Figure 5 A schematic diagram of an electronic device 50 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0145] like Figure 5As shown, the electronic device 50 includes at least one processor 51 and a memory, such as a read-only memory (ROM) 52 and a random access memory (RAM) 53, communicatively connected to the at least one processor 51. The memory stores computer programs executable by the at least one processor. The processor 51 can perform various appropriate actions and processes based on the computer program stored in the ROM 52 or loaded into the RAM 53 from storage unit 58. The RAM 53 can also store various programs and data required for the operation of the electronic device 50. The processor 51, ROM 52, and RAM 53 are interconnected via a bus 54. An input / output (I / O) interface 55 is also connected to the bus 54.

[0146] Multiple components in electronic device 50 are connected to I / O interface 55, including: input unit 56, such as keyboard, mouse, etc.; output unit 57, such as various types of monitors, speakers, etc.; storage unit 58, such as disk, optical disk, etc.; and communication unit 59, such as network card, modem, wireless transceiver, etc. Communication unit 59 allows electronic device 50 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0147] Processor 51 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 51 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 51 performs the various methods and processes described above, such as the Nginx request data acquisition method.

[0148] In some embodiments, the Nginx request data acquisition method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 58. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 50 via ROM 52 and / or communication unit 59. When the computer program is loaded into RAM 53 and executed by processor 51, one or more steps of the Nginx request data acquisition method described above may be performed. Alternatively, in other embodiments, processor 51 may be configured to execute the Nginx request data acquisition method by any other suitable means (e.g., by means of firmware).

[0149] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0150] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0151] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0152] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0153] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0154] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0155] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0156] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method for collecting Nginx request data, characterized in that, include: During the application startup process, the application is identified using the program identification module in the probe tool; If the application is identified as an Nginx application, a temporary Nginx application configuration file is created through the application identification module. Obtain the application configuration file of the Nginx application, and copy the original data in the application configuration file to the temporary configuration file of the Nginx application; Add a module loading directive to the temporary configuration file of the Nginx application to obtain the Nginx application target file; The Nginx probe corresponding to the Nginx application is determined and loaded by the module loading instructions in the Nginx application target file; The Nginx probe listens for business requests received by the Nginx application and collects the first request data of the business requests. When the Nginx application is executed as a reverse proxy service, after forwarding the business request to the backend server, the second request data of the business request is collected through the Nginx probe. The first request data and the second request data are used as the target request data for the Nginx application execution process.

2. The method according to claim 1, characterized in that, The step of determining and loading the Nginx probe corresponding to the Nginx application through the module loading instruction in the Nginx application target file includes: The module loading instructions in the Nginx application target file are used to determine the probe to be loaded corresponding to the Nginx application. The version information of the Nginx application is determined by the module loading instruction to see if it matches the version information of the probe to be loaded; If so, the probe to be loaded will be used as the Nginx probe.

3. The method according to claim 2, characterized in that, After determining whether the version information of the Nginx application matches the version information of the probe to be loaded via the module loading instruction, the method further includes: If the version information of the Nginx application is inconsistent with the version information of the probe to be loaded, then the version information of the Nginx application is used to update the version information of the probe to be loaded. The updated probe to be loaded will be used as an Nginx probe.

4. The method according to any one of claims 1-3, characterized in that, The first request data includes at least one of the following: request method, request link, request header, request start time, and request address; Accordingly, the step of listening to business requests received by the Nginx application through the Nginx probe and collecting the first request data of the business requests includes: The Nginx probe is used to deploy request callback functions during the rewrite phase of the Nginx application execution. The request callback function listens for business requests received by the Nginx application. The request callback function collects the first request data of the business request based on the data structure of the Nginx framework corresponding to the Nginx application.

5. The method according to claim 4, characterized in that, The first request data also includes the request end time and the request response code; Accordingly, the step of listening to business requests received by the Nginx application through the Nginx probe and collecting the first request data of the business requests includes: The request callback function is deployed during the logging phase of the Nginx application execution using the Nginx probe. The request callback function is used to monitor the end time and response code of the business request.

6. The method according to any one of claims 1-3, characterized in that, When the Nginx application is executed as a reverse proxy service and forwards the business request to the backend server, the Nginx probe collects the second request data of the business request, including: When the Nginx application is executed as a reverse proxy service, after forwarding the business request to the backend server, the backend call instructions of the backend server are identified through the Nginx probe. Based on the invocation method corresponding to the backend invocation instruction, collect the second request data of the business request; The second request data includes the calling protocol, the request link, and the request start time.

7. An Nginx request data acquisition device, characterized in that, include: The application identification module is used to identify the application during the application startup process by using the application identification module in the probe tool. The Nginx probe determination module is used to determine and load the Nginx probe corresponding to the Nginx application through the program identification module if the application is identified as an Nginx application. The first request data collection module is used to listen to the business requests received by the Nginx application through the Nginx probe, and collect the first request data of the business requests. The second request data collection module is used to collect the second request data of the business request through the Nginx probe after the business request is forwarded to the backend server when the Nginx application is executed as a reverse proxy service. The target request data determination module is used to use the first request data and the second request data as the target request data for the execution process of the Nginx application. The Nginx probe determination module includes: The temporary configuration file creation unit is used to create a temporary Nginx application configuration file through the program identification module if the application is identified as an Nginx application. The configuration file acquisition unit is used to acquire the application configuration file of the Nginx application and copy the original data in the application configuration file to the temporary configuration file of the Nginx application. The target file acquisition unit is used to add module loading instructions to the Nginx application temporary configuration file to obtain the Nginx application target file; The Nginx probe determination unit is used to determine and load the Nginx probe corresponding to the Nginx application by means of the module loading instructions in the Nginx application target file.

8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the Nginx request data acquisition method according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that are used to cause a processor to execute the Nginx request data acquisition method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Method, device and system for defending against Web attacks

    CN103491060A

  • Data processing method and equipment based on Nginx + Lua

    CN113204386A