Nginx server network topology updating method and related equipment
By monitoring the Nginx process in real time and parsing its configuration files, and updating the network topology of the Nginx server, the problem of difficulty in real-time update and guaranteeing information integrity in the existing technology is solved, and real-time and comprehensive update of the network topology is achieved.
Patent Information
- Application Number
- CN202411584847.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-03-11
AI Technical Summary
The prior art is difficult to update the network topology of Nginx servers in real time, and cannot meet the requirements of security analysis for timeliness and information integrity.
By collecting the processes of the intranet server, we judge whether there is a Nginx process running in real time, and extract forwarding relationship data from its configuration file, parse and update the network topology relationship diagram.
Real-time update of Nginx server network topology is realized, ensuring the timeliness and comprehensiveness of information, and meeting the needs of security analysis.
Smart Images

Figure CN119603160A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure generally relates to the field of communication technology, and in particular to a method, device, server, computer-readable storage medium, and computer program product for updating a network topology of an Nginx server. Background Art
[0002] Nginx server is a widely used forwarding server, which is mainly responsible for forwarding and exchanging network traffic between hosts. In order to understand and manage the flow of requests between Nginx server and backend servers, help system administrators better manage and optimize network architecture, and ensure efficient, stable and secure operation of the system, it is necessary to obtain Nginx forwarding relationships and update the network topology of Nginx server.
[0003] Currently, there are two main methods for updating the network topology of Nginx servers: one is to manually collect Nginx configuration files and analyze them one by one, and the other is to use Nginx forwarding logs to analyze the actual forwarding traffic, and then infer the corresponding forwarding rules based on the actual destination of the forwarding traffic. Among them, the method of manually collecting configuration files can obtain the corresponding forwarding relationship more accurately, but it has a strong lag and cannot meet the timeliness requirements of security analysis. The information collected by the forwarding log analysis method is lacking in comprehensiveness. If the forwarding rule is not executed within a certain period of time, the corresponding forwarding rule cannot be obtained, so it cannot meet the integrity requirements of security analysis.
[0004] Therefore, how to update the network topology of the Nginx server in real time while ensuring the comprehensiveness of the network topology information is an urgent problem to be solved by current technical personnel. Summary of the invention
[0005] In view of the above-mentioned defects or deficiencies in the prior art, it is desired to provide a multi-model integrated learning method, device, server, computer-readable storage medium and computer program product that simultaneously meet the real-time requirements and information comprehensiveness requirements of the network topology update of the Nginx server.
[0006] In a first aspect, an embodiment of the present application provides a method for updating a network topology of an Nginx server, comprising:
[0007] Collect the processes of each server in the intranet to determine whether there is a real-time running Nginx process;
[0008] If it exists, extract the path of the configuration file from the Nginx process, and obtain all corresponding configuration files according to the path;
[0009] Read the configuration file and parse out Nginx forwarding relationship data;
[0010] According to the Nginx forwarding relationship data, the network topology relationship diagram is updated.
[0011] In one embodiment, before updating the network topology relationship diagram according to the Nginx forwarding relationship data, the method further includes:
[0012] Verifying the accuracy of the Nginx forwarding relationship data;
[0013] If the verification is passed, the step of updating the network topology relationship diagram according to the Nginx forwarding relationship data is executed.
[0014] In one embodiment, the accuracy of the Nginx forwarding relationship data is verified, including:
[0015] Collect the forwarding traffic of the Nginx server;
[0016] Determining a forwarding relationship of the forwarded traffic as actual forwarding relationship data;
[0017] A cross-validation comparison is performed on the Nginx forwarding relationship data and the actual forwarding relationship data.
[0018] In one embodiment, parsing the Nginx forwarding relationship data includes:
[0019] Parse the Nginx forwarding relationship data according to the format rules of the forwarding relationship.
[0020] In one embodiment, before parsing the Nginx forwarding relationship data according to the format rule of the forwarding relationship, the method further includes:
[0021] Perform semantic recognition on the configuration file according to the writing rules of the forwarding relationship, and extract data that meets the writing rules as preliminary screening data;
[0022] Accordingly, the Nginx forwarding relationship data is parsed out according to the format rule of the forwarding relationship, specifically: according to the format rule of the forwarding relationship, the Nginx forwarding relationship data is parsed out from the preliminary screening data.
[0023] In one embodiment, after updating the network topology relationship diagram according to the Nginx forwarding relationship data, the method further includes: outputting prompt information of the network topology update.
[0024] In a second aspect, an embodiment of the present application provides a device for updating a network topology of an Nginx server, comprising:
[0025] The process monitoring unit is used to collect the processes of each server in the intranet and determine whether there is a real-time running Nginx process; if so, the configuration file collection unit is triggered;
[0026] The configuration file collection unit is used to extract the path of the configuration file from the Nginx process, and obtain all corresponding configuration files according to the path;
[0027] A forwarding relationship parsing unit, used for reading the configuration file and parsing out Nginx forwarding relationship data;
[0028] The network topology updating unit is used to update the network topology relationship diagram according to the Nginx forwarding relationship data.
[0029] In a third aspect, an embodiment of the present application provides a server, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the embodiment of the present application when executing the program.
[0030] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the embodiment of the present application.
[0031] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the method described in the embodiment of the present application.
[0032] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0034] Figure 1 A schematic diagram of the process of the multi-model ensemble learning method provided in an embodiment of the present application is shown;
[0035] Figure 2 A schematic diagram of an application process provided by an embodiment of the present application is shown;
[0036] Figure 3 An exemplary structural block diagram of a multi-model integrated learning device provided in an embodiment of the present application is shown;
[0037] Figure 4 A schematic diagram of the structure of a computer system suitable for implementing a server of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0038] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the invention are shown in the accompanying drawings.
[0039] It should be noted that, in the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The present application will be described in detail below with reference to the drawings and in combination with the embodiments. Although the embodiments of the present application provide the method operation instruction steps shown in the following embodiments or drawings, more or fewer operation instruction steps may be included in the method based on routine or no creative labor. In the steps where there is no necessary causal relationship logically, the execution order of these steps is not limited to the execution order provided by the embodiments of the present application. The method may be executed in the order of the methods shown in the embodiments or drawings or in parallel during the actual processing process or when the device is executed.
[0040] Please refer to Figure 1 , Figure 1 The flowchart of the method for updating the network topology of an Nginx server provided by an embodiment of the present application is shown. Figure 1 As shown, the method includes:
[0041] S101, collecting the processes of each server in the intranet;
[0042] S102, determine whether there is a real-time running Nginx process; if so, execute step S103;
[0043] The processes running on all servers in the intranet are continuously monitored. Once a running Nginx process is found, step S103 is executed. If not, the monitoring is continuously performed.
[0044] S103, extracting the path of the configuration file from the Nginx process, and obtaining all corresponding configuration files according to the path;
[0045] The configuration file in the Nginx server refers to the file responsible for recording the corresponding forwarding rule pairs during the operation of the Nginx server, which contains the Nginx forwarding relationship. In order to determine the forwarding relationship, it is necessary to extract all configuration files. Specifically, the corresponding Nginx configuration file path is obtained from the process details of the Nginx process, and then all configuration files corresponding to the process are collected according to all configuration file paths and corresponding hierarchical relationships contained in the file.
[0046] S104, read the configuration file and parse out the Nginx forwarding relationship data;
[0047] After obtaining all configuration files of the Nginx process, read the configuration files and parse the Nginx forwarding relationship data from the files. As for the specific implementation method of how to parse the Nginx forwarding relationship data from the configuration files, it can be achieved by analyzing the universality and distinguishability characteristics of the Nginx forwarding relationship data and writing corresponding identification rules. In this embodiment, the specific identification rules are not limited here. In one embodiment, the Nginx forwarding relationship data can be parsed according to the format rules of the forwarding relationship. Since the format of the forwarding relationship is relatively fixed, the corresponding forwarding relationship can be obtained efficiently and accurately using the automatic parsing rules.
[0048] In addition, in order to further improve the accuracy of the analysis, in one embodiment, before parsing the Nginx forwarding relationship data according to the format rules of the forwarding relationship, the configuration file can first be semantically identified according to the writing rules of the forwarding relationship, and the data that meets the writing rules can be extracted as the preliminary screening data. That is, the data that meets the writing rules is first extracted from the configuration file through semantic recognition to obtain the preliminary screening data, and then only the preliminary screening data is parsed according to the format rules of the forwarding relationship to obtain the Nginx forwarding relationship data. Using semantic recognition to filter some custom writing habits in advance can avoid their impact on the accuracy of format rule recognition and further improve the recognition accuracy. In this embodiment, only the above-mentioned Nginx forwarding relationship data parsing method is used as an example for introduction. Other parsing methods can refer to the introduction of this embodiment and will not be repeated here.
[0049] S105. Update the network topology diagram according to the Nginx forwarding relationship data.
[0050] After obtaining the Nginx forwarding relationship data, it is updated in real time to the network topology diagram of the Nginx server to ensure the accuracy of the network topology in the intranet.
[0051] Optionally, in one embodiment, after executing step S105 and updating the network topology relationship diagram according to the Nginx forwarding relationship data, in order to improve the user experience, a step of outputting prompt information of the network topology update can be further performed to remind relevant technical personnel after each network topology update, so that relevant technical personnel can timely perform troubleshooting and optimize the network architecture according to the updated network topology, thereby ensuring the efficient, stable and safe operation of the system. Of course, the prompt information may not be output after the data is updated, which is not limited in this embodiment and can be set accordingly according to actual use needs.
[0052] It should be noted that although the operations of the method of the present invention are described in a particular order in the drawings, this does not require or imply that the operations must be performed in this particular order or that all illustrated operations must be performed to achieve desired results.
[0053] Based on the above introduction, the method provided in this embodiment continuously monitors the processes run by all servers in the intranet. If a running Nginx process is found, the path of the Nginx configuration file is extracted from it, and all corresponding configuration files are obtained according to the path. The configuration file records the corresponding forwarding rules during the operation of the Nginx server, reads the configuration file, parses the Nginx forwarding relationship data from it, and then updates the network topology relationship diagram according to the parsed Nginx forwarding relationship data. Among them, the update process of the above network topology relationship is triggered while the real-time Nginx process is running, that is, the configuration file of the Nginx server is identified and collected through real-time monitoring, which ensures the timeliness of the update; in addition, since the configuration file contains all the forwarding rules in operation, by parsing the forwarding relationship data of all configuration files, the information randomness problem caused by parsing the actual forwarding traffic is avoided, thereby ensuring the comprehensiveness of the collected Nginx forwarding relationship data. Therefore, this method can simultaneously meet the real-time requirements and information comprehensiveness requirements of the network topology update of the Nginx server.
[0054] In one embodiment, in order to further ensure the accuracy of the parsed Nginx forwarding relationship data, before executing step S105 to update the network topology relationship diagram according to the Nginx forwarding relationship data, the process may jump to step S106.
[0055] Step S106, verify the accuracy of the Nginx forwarding relationship data; if the verification passes, execute step S105.
[0056] The accuracy and reliability of network topology update information can be further improved.
[0057] The specific verification means are not limited in this embodiment. In one embodiment, the accuracy verification of Nginx forwarding relationship data can be performed according to the following steps:
[0058] Step S61, collecting the forwarding traffic of the Nginx server;
[0059] Step S62: determining the forwarding relationship of the forwarded traffic as actual forwarding relationship data;
[0060] Step S63: cross-validate and compare the Nginx forwarding relationship data with the actual forwarding relationship data.
[0061] The forwarding relationship obtained by parsing the configuration file is cross-validated and compared with the forwarding relationship in the actual traffic. If the analysis result is consistent with the actual data, the credibility of the parsed forwarding relationship can be increased, significantly reducing the risk caused by inaccurate data.
[0062] If the accuracy verification fails, this is not limited in the present embodiment, and the data may be discarded or outputted with a prompt message indicating verification failure for verification by relevant technical personnel, etc. In the present embodiment, only the above two methods are taken as examples, and other methods may refer to the introduction of the present embodiment and will not be described in detail here.
[0063] In order to deepen the understanding of the Nginx server network topology update method provided by this application, this embodiment introduces a specific application process, such as Figure 2 The following is a schematic diagram of the application process. The specific process is as follows:
[0064] 1. Process monitoring. Continuously monitor the processes running on all servers in the intranet. Once a running Nginx process is found, extract the corresponding server. If it does not exist, continue to monitor.
[0065] 2. Configuration file collection: First, you need to obtain the corresponding Nginx configuration file path through the process details, and then collect all configuration files corresponding to the process based on all configuration file paths and corresponding hierarchical relationships contained in the file.
[0066] 3. Use semantic recognition to filter some custom writing habits.
[0067] 4. Use automatic parsing rules to parse the corresponding forwarding relationship.
[0068] 5. Cross-validation: Cross-validate and compare the forwarding relationship obtained in step 4 with the forwarding relationship in the actual traffic.
[0069] 6. Update the forwarding relationship that passes the cross-validation comparison to the network topology diagram in real time.
[0070] It should be noted that this embodiment only introduces an implementation method of one process, and the selection and coordination of other steps can refer to the introduction of this embodiment and will not be repeated here.
[0071] Further references Figure 3 , which shows an exemplary structural block diagram of an Nginx server network topology updating device according to an embodiment of the present application, which mainly includes:
[0072] The process monitoring unit 101 is used to collect the processes of each server in the intranet and determine whether there is a real-time running Nginx process; if so, the configuration file collection unit 102 is triggered;
[0073] The configuration file collection unit 102 is used to extract the path of the configuration file from the Nginx process and obtain all corresponding configuration files according to the path;
[0074] The forwarding relationship parsing unit 103 is used to read the configuration file and parse out the Nginx forwarding relationship data;
[0075] The network topology updating unit 104 is used to update the network topology relationship diagram according to the Nginx forwarding relationship data.
[0076] It should be understood that the units described in the above device are similar to those in the reference Figure 1 The steps in the method described above correspond to each other. Therefore, the operations and features described above for the method are also applicable to the device and the units contained therein, and will not be repeated here. The device can be pre-implemented in the browser or other security application of the server, or loaded into the browser or its security application of the server by downloading or the like. The corresponding units in the device can cooperate with the units in the server to implement the solution of the embodiment of the present application.
[0077] For the several units mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more units described above can be embodied in one unit. On the contrary, the features and functions of one unit described above can be further divided into multiple units to be embodied.
[0078] It should be noted that for details not disclosed in the Nginx server network topology updating device in the embodiment of the present application, please refer to the details disclosed in the above embodiments of the present application, which will not be repeated here.
[0079] Reference below Figure 4 , Figure 4 A schematic diagram of the structure of a computer system suitable for implementing a server of an embodiment of the present application is shown.
[0080] like Figure 4 As shown, the computer system includes a central processing unit (CPU) 401, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 402 or the program loaded from the storage part 408 into the random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation instructions of the system are also stored. The CPU 401, the ROM 402, and the RAM 403 are connected to each other through a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0081] The following components are connected to the I / O interface 405: an input section 406 including a keyboard, a mouse, etc.; an output section 407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN card, a modem, etc. The communication section 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to the I / O interface 405 as needed. A removable medium 411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 410 as needed, so that a computer program read therefrom is installed into the storage section 408 as needed.
[0082] In particular, according to an embodiment of the present application, the above reference flow chart Figure 1 The described process can be implemented as a computer software program. For example, an embodiment of the present application includes 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 flow chart. In such an embodiment, the computer program includes a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 409, and / or installed from the removable medium 411. When the computer program is executed by the central processing unit (CPU) 401, the above-mentioned functions defined in the system of the present application are executed.
[0083] It should be noted that the computer-readable medium shown in the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can 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 the present application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal can take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium such as a computer-readable storage medium that can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0084] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operating instructions of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the aforementioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, the boxes represented by two connections 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 box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operating instruction, or can be implemented with a combination of dedicated hardware and computer instructions.
[0085] The units or modules involved in the embodiments described in the present application may be implemented by software or hardware. The units or modules described may also be arranged in a processor. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves.
[0086] As another aspect, the present application further provides a computer-readable storage medium, which may be included in the server described in the above embodiment, or may exist independently without being assembled into the server. The above computer-readable storage medium stores one or more programs, and when the above programs are used by one or more processors to execute the Nginx server network topology update method described in the present application.
[0087] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the aforementioned disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.
Claims
1. A method for updating the network topology of an Nginx server, characterized in that: include: Collect the processes of each server in the intranet to determine whether there is a real-time running Nginx process; If it exists, extract the path of the configuration file from the Nginx process, and obtain all corresponding configuration files according to the path; Read the configuration file and parse out Nginx forwarding relationship data; According to the Nginx forwarding relationship data, the network topology relationship diagram is updated.
2. The method according to claim 1, characterized in that Before updating the network topology relationship diagram according to the Nginx forwarding relationship data, the method further includes: Verifying the accuracy of the Nginx forwarding relationship data; If the verification is passed, the step of updating the network topology relationship diagram according to the Nginx forwarding relationship data is executed.
3. The method according to claim 2, characterized in that Verifying the accuracy of the Nginx forwarding relationship data includes: Collect the forwarding traffic of Nginx server; Determining a forwarding relationship of the forwarded traffic as actual forwarding relationship data; A cross-validation comparison is performed on the Nginx forwarding relationship data and the actual forwarding relationship data.
4. The method according to claim 1, characterized in that The parsing of Nginx forwarding relationship data includes: Parse the Nginx forwarding relationship data according to the format rules of the forwarding relationship.
5. The method according to claim 4, characterized in that Before parsing the Nginx forwarding relationship data according to the format rule of the forwarding relationship, the method further includes: Perform semantic recognition on the configuration file according to the writing rules of the forwarding relationship, and extract data that meets the writing rules as preliminary screening data; Accordingly, the Nginx forwarding relationship data is parsed out according to the format rule of the forwarding relationship, specifically: according to the format rule of the forwarding relationship, the Nginx forwarding relationship data is parsed out from the preliminary screening data.
6. The method according to claim 1, characterized in that After updating the network topology relationship diagram according to the Nginx forwarding relationship data, the method further includes: outputting prompt information of the network topology update.
7. A device for updating network topology of Nginx server, characterized in that: include: The process monitoring unit is used to collect the processes of each server in the intranet and determine whether there is a real-time running Nginx process; If it exists, the configuration file collection unit is triggered; The configuration file collection unit is used to extract the path of the configuration file from the Nginx process, and obtain all corresponding configuration files according to the path; A forwarding relationship parsing unit, used for reading the configuration file and parsing out Nginx forwarding relationship data; The network topology updating unit is used to update the network topology relationship diagram according to the Nginx forwarding relationship data.
8. A server comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.