A Nginx configuration detection method and device for network range system
The environment and system variables of the network shooting range system are obtained through automated detection scripts, and Nginx configuration files are automatically detected, which solves the problem of lagging Nginx configuration inspection in the network shooting range system, achieving efficient and accurate configuration detection and repair.
Patent Information
- Application Number
- CN202410856773.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-06-28
AI Technical Summary
The current network shooting range system has a certain lag in checking Nginx configuration, mainly relying on manual audits or log analysis after errors occur, which is inefficient and difficult to prevent before problems occur.
It provides an Nginx configuration detection method, which obtains the environment variables of the network shooting range system and the system variables of the operating system through automated detection scripts, and automatically detects the Nginx configuration file based on these variables to generate a detection report.
Without relying on manual audits, the detection results of the configuration file can be automatically obtained and automated inspection reports can be obtained before starting the network shooting range system to serve as the basis for configuration repair, thereby improving configuration accuracy and system stability.
Smart Images

Figure CN118802520B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to an Nginx configuration detection method and device for a network range system. Background Art
[0002] As a test platform for simulating network attacks and defenses, the network range system generally runs on a Linux server, with data forwarding between the front and back ends based on Nginx. Due to the large number of businesses involved, traditional single front-end applications are prone to code base expansion, slow compilation, and excessive resource consumption when facing diversified functional modules. The introduction of the micro-front-end architecture effectively solves this challenge by decomposing large applications into multiple independent small micro-front-end sub-applications, achieving modular and efficient development and maintenance.
[0003] However, the micro-frontend architecture brings with it a series of complex Nginx configuration issues, including but not limited to load balancing, port mapping, cross-domain policies, etc. The correctness of these configurations directly affects whether the system can operate normally. Currently, most network range systems have a certain lag in checking Nginx configurations, and currently rely mainly on manual review or log analysis after errors occur, which is not only inefficient, but also difficult to prevent problems before they occur. Summary of the invention
[0004] The invention provides an Nginx configuration detection method for a network target range system to realize the detection of the Nginx configuration.
[0005] According to a first aspect of the present invention, there is provided an Nginx configuration detection method for a network range system, comprising: starting an Nginx configuration automation detection script when an Nginx configuration detection instruction is received;
[0006] Obtaining the environment variables of the network range system and the system variables of the operating system through the Nginx configuration automated detection script, wherein the network range system runs on the operating system;
[0007] Reading the Nginx configuration file loaded into the network range system through the Nginx configuration automation detection script, and automatically detecting the Nginx configuration file based on the environment variables and the system variables;
[0008] Generate an automated detection report for the Nginx configuration file based on the automated detection results.
[0009] According to another aspect of the present invention, there is provided a verification device for Nginx configuration of a network range system, comprising:
[0010] The detection script startup module is used to start the Nginx configuration automatic detection script when receiving the Nginx configuration detection instruction;
[0011] An environment variable and system variable acquisition module, used to acquire the environment variables of the network range system and the system variables of the operating system through the Nginx configuration automatic detection script, wherein the network range system runs on the operating system;
[0012] An automated detection module, configured to read an Nginx configuration file loaded into the network range system through the Nginx configuration automated detection script, and to perform automated detection on the Nginx configuration file based on the environment variables and the system variables;
[0013] The detection report generation module is used to generate an automated detection report for the Nginx configuration file based on the automated detection results.
[0014] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0015] at least one processor; and
[0016] a memory communicatively connected to the at least one processor; wherein,
[0017] The memory stores a computer program that can be executed by the at least one processor. The computer program is executed by the at least one processor so that the at least one processor can perform the method described in any embodiment of the present invention.
[0018] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method described in any embodiment of the present invention when executed.
[0019] The technical solution of the embodiment of the present invention obtains the environment variables of the network target range system and the system variables of the operating system through an automated detection script, and performs automated detection on the Nginx configuration file based on the environment variables and the system variables, so that the detection results of the configuration file can be automatically obtained without relying on manual review, and an automated detection report can be obtained before starting the network target range system as a basis for configuration repair, thereby improving the configuration accuracy and system stability.
[0020] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0022] Figure 1 It is a flow chart of an Nginx configuration detection method for a network range system provided according to the first embodiment of the present invention;
[0023] Figure 2 It is a flow chart of an Nginx configuration detection method for a network range system provided according to Embodiment 2 of the present invention;
[0024] Figure 3 It is a structural schematic diagram of an Nginx configuration detection device for a network target range system provided according to Embodiment 3 of the present invention;
[0025] Figure 4 It is a schematic diagram of the structure of an electronic device provided by Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] Embodiment 1
[0029] Figure 1A flowchart of a method for detecting Nginx configuration for a network range system is provided for the first embodiment of the present invention. This embodiment is applicable to the case of detecting Nginx configuration. The method can be performed by an Nginx configuration detection device for a network range system, which can be implemented in the form of hardware and / or software. Figure 1 As shown, the method includes:
[0030] Step S101, when receiving the Nginx configuration detection instruction, start the Nginx configuration automatic detection script.
[0031] Optionally, before starting the Nginx configuration automation detection script when receiving the Nginx configuration detection instruction, it also includes: receiving configuration writing instructions for the front-end base and sub-applications in the network target range system, wherein the front-end base is respectively associated with each sub-application; and creating an Nginx configuration file for the front-end base and sub-application according to the configuration writing instructions.
[0032] Specifically, this implementation is mainly aimed at the network range system based on the micro-frontend architecture, and before performing the Nginx configuration test, the parameters of the front-end base and each sub-application in the system will be configured according to the user's instructions to obtain the corresponding Nginx configuration file. For example, basic forwarding rules are set for the front-end base, including but not limited to the default HTTPS listening settings, basic error handling page configuration, and sub-application routing definitions; for each sub-application, a specific routing prefix, resource file path, and proxy forwarding rules are written. Of course, this implementation is only an example, and does not limit the specific content of the configuration file.
[0033] Among them, the network target range system runs on an operating system, such as a Linux operating system, and an Nginx configuration automation detection script is pre-set on the operating system. In this implementation, before the network target range system is officially started, the Nginx configuration of the network target range system can be detected by executing the Nginx configuration automation detection script. Therefore, when the Nginx configuration detection instruction is received, a pre-written Python script will be started through the command line. The script is responsible for automatically checking a series of standard and custom rules of the Nginx configuration file.
[0034] Step S102, obtaining the environment variables of the network target range system and the system variables of the operating system through Nginx configuration automatic detection script.
[0035] Among them, the environment variables of the network range system and the system variables of the operating system are obtained by configuring the automatic detection script of Nginx, including: extracting the high concurrency scenario support status and deployment environment of the network range system through the automatic detection script of Nginx configuration, and using the high concurrency scenario support status and deployment environment as environment variables, wherein the deployment environment includes the development environment, the test environment and the production environment; extracting the number of CPU cores and disk space of the operating system through the automatic detection script of Nginx configuration, and using the number of CPU cores and disk space as system variables. Of course, this implementation is only an example, and does not limit the specific content of the environment variables and system variables.
[0036] It should be noted that, in this embodiment, after obtaining the environment variables and system variables, the environment variables and system variables can be used as the basis for subsequent Nginx configuration file detection to detect different configuration items in the Nginx configuration file, thereby ensuring the accuracy of the detection.
[0037] Step S103, read the Nginx configuration file loaded into the network target range system through the Nginx configuration automation detection script, and perform automatic detection on the Nginx configuration file based on environment variables and system variables.
[0038] Optionally, the Nginx configuration file is automatically detected based on environment variables and system variables, including: automatically detecting the first type of configuration items in the Nginx configuration file corresponding to the front-end base and sub-applications based on environment variables and system variables; and automatically detecting the second type of configuration items in the Nginx configuration file corresponding to the front-end base based on environment variables and system variables.
[0039] Specifically, in this implementation, the first type of configuration items in the Nginx configuration files corresponding to the front-end base and sub-applications will be automatically detected, that is, the same configuration items in the Nginx configuration files corresponding to the front-end base and sub-applications will be detected, where the first type of configuration items include: working process configuration, access log configuration, static resource compression configuration, cross-domain configuration, port occupancy and port consistency. Of course, this implementation is only an example, and does not limit the specific types of the first type of configuration items. The following is a specific description of the detection process of each first type of configuration item: The first item, the detection of the working process configuration, in this implementation, it will read Take each Nginx configuration file and extract the working process parameters, such as worker_processes, and determine whether the working process parameters are correct. The working process parameter determination rules can be set in advance. For example, determine whether the current system supports high concurrency based on the high concurrency support status in the environment variable. If high concurrency is supported, obtain the number of CPU cores in the system variable, and require that the process parameter must be the same as the number of CPU cores. If high concurrency is not supported, the process parameter must be 1. When it is determined that the process parameters extracted from the Nginx configuration file meet the above determination rules, it is determined that the working process configuration test has passed, otherwise it is determined that the working process configuration test has failed. The second item, the detection of access log configuration, in this embodiment, each Nginx configuration file will be read and the log access status parameter, for example, access_log, will be extracted, and the log access status parameter will be judged whether it is correct. The log access status parameter judgment rule can be pre-set, for example, according to the disk space in the system variable, it is determined whether the current system hard disk resources are sufficient. If not, the log access status parameter should be closed log record, if sufficient, the log access status parameter should be opened log record, and the log level is Error level. If the development environment is deployed, the log level is set to Info level to facilitate problem location. When it is determined that the log access status parameter extracted from the Nginx configuration file meets the above judgment rules, it is determined that the access log configuration detection has passed, otherwise it is determined that the access log configuration detection has not passed. The third item, the detection of static resource compression configuration, in this embodiment, each Nginx configuration file will be read and the file compression type will be obtained, and it is determined whether the file compression type is Gzip format compression of static resources such as JavaScript, JSON, JPEG, PNG, etc. If it is determined that the Nginx configuration file contains the file compression type and it is the type specified above, it is determined that the static resource compression configuration detection has passed, otherwise it is determined that the static resource compression configuration detection has not passed.Fourth, detection of cross-domain configuration. In this implementation, the cross-domain identifier in each Nginx configuration file will be read, and it will be determined whether the cross-domain identifier is correct. The cross-domain identifier determination rules can be pre-set. For example, the deployment environment in the environment variables of the network target range system is obtained. When the deployment environment is a development environment, a cross-domain identifier is required to indicate that cross-domain is allowed. When the deployment environment is a test environment and a production environment, a cross-domain identifier is required to indicate that cross-domain is restricted. Therefore, when it is determined that the cross-domain identifier meets the above determination rules, it is determined that the cross-domain identifier detection has passed. Otherwise, it is determined that the cross-domain identifier detection has not passed. Fifth, detection of port occupancy. In this implementation, the port identifier in the Nginx configuration file corresponding to each sub-application will be read, and it will be determined whether the port identifiers contained in different Nginx configuration files are reused. If there is no reuse, it is determined that the port occupancy detection has passed. If there is repeated occupancy, it is determined that the port occupancy detection has not passed. Item 6. Port consistency detection. Since the port identifier of each sub-application is recorded in the Nginx configuration file corresponding to the front-end base, and the sub-application container port pointed to by the proxy_pass instruction of the front-end base, and the port identifier of the sub-application itself is recorded in the Nginx configuration file corresponding to the sub-application, when the sub-application container port pointed to by the proxy_pass instruction of the front-end base matches the listen port identifier configured by the sub-application itself, it is determined that the port consistency detection has passed; otherwise, it is determined that the port consistency detection has failed.
[0040] In addition, in this embodiment, only the second type of configuration items in the Nginx configuration file corresponding to the front-end base will be automatically detected, that is, the specific configuration items in the Nginx configuration file corresponding to the front-end base will be detected, wherein the second type of configuration items include: gateway service configuration, port opening configuration, sub-application routing configuration and jump page configuration. The following is a specific description of the detection process of each second type of configuration item: The first item, the detection of the gateway service configuration, in this embodiment, the number of gateway service servers in the Nginx configuration file corresponding to the front-end base will be read, and it will be determined whether the number of servers is correct. The server number determination rule can be pre-set, for example, according to the high concurrency support status in the environment variable, it is determined whether the current system supports high concurrency. If high concurrency is supported, the number of servers needs to be greater than 1 to achieve load balancing. If high concurrency is not supported, the number of servers needs to be 1. When it is determined that the number of servers meets the above determination rules, it is determined that the gateway service configuration detection has passed, otherwise it is determined that the gateway service configuration detection has not passed. The second item is the detection of port opening configuration. In this implementation, the deployment environment in the environment variables of the network target range system is obtained, and the port opening rules are pre-set. For example, when the deployment environment is a test environment and a production environment, the front-end base Nginx configuration needs to open the necessary HTTPS port (443) and close the non-encrypted HTTP port (80). When the deployment environment is a development environment, the HTTP port (80) needs to be opened. When it is determined that the actual status of port (443) and port (80) meets the above-mentioned judgment rules, it is determined that the port opening configuration detection has passed; otherwise, it is determined that the port opening configuration detection has failed. The third item is the detection of sub-application routing configuration. The detection of sub-application routing configuration in this implementation mainly includes three aspects. The first aspect is to detect whether the location of the sub-application resource agent is lost, verify the routing configuration of each sub-application, and ensure that the necessary location block exists to avoid the request not being able to find the corresponding processing logic; the second aspect is to detect whether the location naming of the sub-application resource agent is correct, and automatically check the consistency of the sub-application default routing prefix in the front-end base Nginx configuration file and the routing prefix of the sub-application resource file. For example, when the competition sub-application agent forwards, it is necessary to ensure the naming consistency between the default routing prefix location / competition and the routing prefix location / competition-res of the sub-application resource file, and the content competition before the "-" must be consistent; the third aspect is to detect whether the front-end base location configuration is repeated, traverse the front-end base nginx.conf configuration file, identify and report any repeated location configurations, and prevent requests from being processed incorrectly or causing service abnormalities.The fourth item is the detection of jump page configuration. In this implementation, it will detect whether the abnormal jump page error_page is configured in the front-end base Nginx configuration file, and when an error occurs, it can correctly jump to the pre-defined friendly error page. When it is determined that the abnormal jump page is configured and the page can jump normally, it is determined that the jump page configuration detection has passed, otherwise it is determined that the jump page configuration detection has failed.
[0041] Step S104, generating an Nginx configuration file automated detection report according to the automated detection result.
[0042] Optionally, an automated detection report for the Nginx configuration file is generated based on the automated detection results, including: generating a report overview based on the automated detection time, the environment variables of the network target range system, and the network target range system version; obtaining the overall status of each configuration item in the automated detection, and generating a detection result overview based on the overall status; obtaining the detection results of each configuration item in the automated detection, and generating detailed inspection results based on the detection results; determining a modification suggestion rectification plan based on the detection results of each configuration item; generating an automated detection report for the Nginx configuration file based on the report overview, detection result overview, detailed inspection results, and modification suggestion rectification plan.
[0043] Specifically, in this implementation, an automated detection report for the Nginx configuration file will be generated based on the automated detection results, wherein the generated automated detection report includes a report overview, a detection result overview, detailed inspection results, and modification suggestions and rectification plans. Of course, this implementation is only an example and does not limit the content of the automated detection report.
[0044] The report overview includes the report topic, such as "Network Range Micro-frontend Architecture Nginx Configuration Automated Verification Report", the specific date and time when the report was generated, and the version number of the network range system, environmental parameters (such as whether it supports high concurrency, environment type, etc.). The test result overview includes the overall status and key issue summary. The overall status uses "pass / fail" or "success / failure" to briefly indicate the compliance of the entire configuration. The key issue summary lists the most urgent or most influential issues, such as port conflicts and missing important configurations. The detailed inspection results include working process configuration, gateway service configuration, access log configuration, port opening, static resource compression, sub-application routing configuration, cross-domain policy, port occupancy, port consistency check and error handling configuration. Among them, working process configuration: display the number of working processes actually configured in the front-end base nginx.conf and compare it with the recommended value, marking the configuration that does not meet the requirements; gateway service configuration: list the number of servers of the front-end base gateway and mark whether it meets the high concurrency requirements; access log configuration: indicate the matching degree between the logging strategy (on / off, log level) and the hardware resources; port opening: confirm the HTTPS (443) port Whether the port is correctly opened and whether the HTTP (80) port is reasonably disabled; static resource compression: list the file types that have been configured for compression, and mark missing or inappropriate compression settings; sub-application routing configuration: list the location configuration of each sub-application in detail, including whether it is lost, whether the name is correct, and whether it is repeated; cross-domain strategy: indicate whether the cross-domain configuration under different environments (development / testing / production) meets expectations; port occupation: check port usage and identify reused ports; port consistency check: verify whether the port mapping between the front-end base and the sub-application front-end container is consistent; error handling configuration: confirm the validity of the error page configuration and the actual jump effect. The modification suggestion rectification plan provides specific modification suggestions and operation guidelines for each problem found to help quickly correct the configuration. In addition, an appendix can also be included in the automated detection report, for example, to support the download of the inspection script and the download of the verification log, so as to facilitate the user's in-depth analysis. Of course, this embodiment is only an example, and does not limit the specific content contained in the automated detection report.
[0045] It is worth mentioning that the implementation of the present invention significantly improves the Nginx configuration management efficiency under the network target range micro-frontend architecture, and the specific effects are reflected in: (1) Improving system stability and reliability: Through automated inspection and dynamic adjustment of inspection rules, service interruptions caused by Nginx configuration errors are significantly reduced, and the overall stability and reliability of the system are improved. (2) Reducing operation and maintenance costs and time: The Nginx configuration automated verification and early warning reporting mechanism greatly shortens the time of manual inspection, reduces operation and maintenance costs, and enables operation and maintenance personnel to locate and solve problems more quickly. (3) Optimizing development iteration efficiency: Intelligent cross-domain strategies adapt to the needs of different development stages, promote rapid iteration, and ensure the security of the production environment. (4) Enhancing configuration consistency and coordination: Automatically detecting and maintaining configuration consistency between sub-applications in the micro-frontend architecture avoids routing conflicts and communication barriers, and ensures efficient coordination between microservices. (5) Improving user experience: By ensuring the correct configuration and efficient processing of error pages, as well as optimized static resource compression strategies, the access experience of end users is improved. In summary, the present invention provides a comprehensive and efficient automated verification solution for Nginx configuration management under the network target range micro-frontend architecture, which not only solves the limitations of traditional manual management, but also significantly improves the stability and operation and maintenance efficiency of the system, laying a solid foundation for the widespread application of the micro-frontend architecture.
[0046] In the implementation mode of the present application, the environment variables of the network target range system and the system variables of the operating system are obtained through an automated detection script, and the Nginx configuration file is automatically detected based on the environment variables and system variables, so that the detection results of the configuration file can be automatically obtained without relying on manual review, and an automated detection report can be obtained before starting the network target range system as a basis for configuration repair, thereby improving the configuration accuracy and system stability.
[0047] Embodiment 2
[0048] Figure 2 The flowchart of a method for detecting Nginx configuration for a network range system provided in the second embodiment of the present invention is based on the above embodiment. After generating an automated detection report for the Nginx configuration file according to the automated detection result, the present embodiment further includes: reviewing the automated detection report, and starting the network range system when it is determined that the review is passed. Figure 2 As shown, the method includes:
[0049] Step S201, when receiving the Nginx configuration detection instruction, start the Nginx configuration automatic detection script.
[0050] Optionally, before starting the Nginx configuration automation detection script when receiving the Nginx configuration detection instruction, it also includes: receiving configuration writing instructions for the front-end base and sub-applications in the network target range system, wherein the front-end base is respectively associated with each sub-application; and creating an Nginx configuration file for the front-end base and sub-application according to the configuration writing instructions.
[0051] Step S202, obtain the environment variables of the network target range system and the system variables of the operating system through Nginx configuration automatic detection script.
[0052] Step S203, read the Nginx configuration file loaded into the network target range system through the Nginx configuration automation detection script, and perform automatic detection on the Nginx configuration file based on environment variables and system variables.
[0053] Optionally, the Nginx configuration file is automatically detected based on environment variables and system variables, including: automatically detecting the first type of configuration items in the Nginx configuration file corresponding to the front-end base and sub-applications based on environment variables and system variables; and automatically detecting the second type of configuration items in the Nginx configuration file corresponding to the front-end base based on environment variables and system variables.
[0054] Step S204, generating an Nginx configuration file automated detection report according to the automated detection result.
[0055] Optionally, an automated detection report for the Nginx configuration file is generated based on the automated detection results, including: generating a report overview based on the automated detection time, the environment variables of the network target range system, and the network target range system version; obtaining the overall status of each configuration item in the automated detection, and generating a detection result overview based on the overall status; obtaining the detection results of each configuration item in the automated detection, and generating detailed inspection results based on the detection results; determining a modification suggestion rectification plan based on the detection results of each configuration item; generating an automated detection report for the Nginx configuration file based on the report overview, detection result overview, detailed inspection results, and modification suggestion rectification plan.
[0056] Step S205, review the automated detection report, and start the network range system when it is determined that the review is passed.
[0057] Specifically, in this implementation, after obtaining the test report through automated testing of the Nginx configuration, the test report will be reviewed. If it is determined based on the detailed inspection results in the test report that all items in the Nginx configuration have passed, the review is determined to have passed, and the network target range system is started after the review passes. At that time, when it is determined through the review that there are test items in the detailed inspection results that have failed the test, they can be marked with a prominent logo to prompt the user to quickly repair the problematic configuration items, so that before the network target range system is run, the user can refer to the test report to correct the obviously erroneous configuration items in the network target range system, thereby ensuring the accuracy of the configuration and the stability of the network target range system during operation, thereby avoiding service startup failures or abnormal operations due to improper configuration.
[0058] In the implementation mode of the present application, the environment variables of the network target range system and the system variables of the operating system are obtained through an automated detection script, and the Nginx configuration file is automatically detected based on the environment variables and system variables, so that the detection results of the configuration file can be automatically obtained without relying on manual review, and an automated detection report can be obtained before starting the network target range system as a basis for configuration repair, thereby improving the configuration accuracy and system stability.
[0059] Embodiment 3
[0060] Figure 3 This is a schematic diagram of the structure of an Nginx configuration detection device for a network target range system provided by the third embodiment of the present invention. Figure 3 As shown, the device includes: a detection script starting module 310, an environment variable and system variable acquisition module 320, an automatic detection module 330 and a detection report generation module 340.
[0061] Wherein, the detection script starting module 310 is used to start the Nginx configuration automatic detection script when receiving the Nginx configuration detection instruction;
[0062] An environment variable and system variable acquisition module 320 is used to acquire the environment variables of the network range system and the system variables of the operating system by configuring an automatic detection script in Nginx, wherein the network range system runs on the operating system;
[0063] The automated detection module 330 is used to read the Nginx configuration file loaded into the network range system through the Nginx configuration automated detection script, and perform automated detection on the Nginx configuration file based on the environment variables and the system variables;
[0064] The detection report generating module 340 is used to generate an automatic detection report of the Nginx configuration file according to the automatic detection result.
[0065] Optionally, the device further includes a configuration file writing module, which is used to receive configuration writing instructions for the front-end base and sub-applications in the network range system, wherein the front-end base is associated with each sub-application respectively;
[0066] Create Nginx configuration files for the front-end base and sub-applications according to the configuration writing instructions.
[0067] Optionally, an environment variable and system variable acquisition module is used to extract the high-concurrency scenario support status and deployment environment of the network range system through the Nginx configuration automatic detection script, and use the high-concurrency scenario support status and deployment environment as environment variables, where the deployment environment includes the development environment, the test environment, and the production environment;
[0068] Configure the Nginx automated detection script to extract the number of CPU cores and disk space of the operating system, and use the number of CPU cores and disk space as system variables.
[0069] Optionally, an automatic detection module is used to automatically detect the first type of configuration items in the Nginx configuration files corresponding to the front-end base and sub-applications based on environment variables and system variables;
[0070] Automatically detect the second type of configuration items in the Nginx configuration file corresponding to the front-end base based on environment variables and system variables.
[0071] Optional, the first category of configuration items includes: work process configuration, access log configuration, static resource compression configuration, cross-domain configuration, port occupation and port consistency;
[0072] The second category of configuration items includes: gateway service configuration, port opening configuration, sub-application routing configuration and jump page configuration.
[0073] Optionally, a detection report generation module is used to generate a report overview based on the automated detection time, the environment variables of the network range system, and the network range system version;
[0074] Obtain the overall status of each configuration item in the automated test and generate a test result summary based on the overall status;
[0075] Obtain the test results of each configuration item in the automated test, and generate detailed inspection results based on the test results;
[0076] Determine the modification suggestion and rectification plan based on the test results of each configuration item;
[0077] Generate an automated detection report for the Nginx configuration file based on the report overview, detection result overview, detailed inspection results, and modification suggestions and rectification plans.
[0078] Optionally, the device also includes a test report review module, which is used to review the automated test report and start the network target range system when it is determined that the review is passed.
[0079] The Nginx configuration detection device for a network target range system provided by an embodiment of the present invention can execute the Nginx configuration detection method for a network target range system provided by any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.
[0080] Embodiment 4
[0081] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment 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 processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0082] like Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0083] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0084] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 executes the various methods and processes described above, such as a verification method for the Nginx configuration of the network range system.
[0085] In some embodiments, the verification method for the Nginx configuration of the network range system can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the verification method for the Nginx configuration of the network range system described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to execute the verification method for the Nginx configuration of the network range system in any other appropriate manner (for example, by means of firmware).
[0086] Various implementations 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 chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0087] Computer programs for implementing 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, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0088] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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 foregoing.
[0089] To provide interaction with a user, the systems and techniques described herein may 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 a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0090] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0091] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0092] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0093] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A Nginx configuration detection method for a network range system, characterized in that: include: When receiving the Nginx configuration detection instruction, start the Nginx configuration automatic detection script; Obtaining the environment variables of the network range system and the system variables of the operating system through the Nginx configuration automated detection script, wherein the network range system runs on the operating system; Reading the Nginx configuration file loaded into the network range system through the Nginx configuration automation detection script, and automatically detecting the Nginx configuration file based on the environment variables and the system variables; Generate an automated detection report for the Nginx configuration file based on the automated detection results; Wherein, before starting the Nginx configuration automatic detection script when receiving the Nginx configuration detection instruction, it also includes: Receiving configuration writing instructions for the front-end base and sub-applications in the network range system, wherein the front-end base is associated with each of the sub-applications respectively; Create the Nginx configuration file for the front-end base and the sub-application according to the configuration writing instructions.
2. The method according to claim 1, characterized in that: The step of obtaining the environment variables of the network range system and the system variables of the operating system by configuring the automatic detection script of Nginx includes: Extracting the high-concurrency scenario support status and deployment environment of the network range system through the Nginx configuration automation detection script, and using the high-concurrency scenario support status and the deployment environment as the environment variables, wherein the deployment environment includes a development environment, a test environment, and a production environment; The number of CPU cores and disk space of the operating system are extracted by configuring the Nginx automated detection script, and the number of CPU cores and the disk space are used as the system variables.
3. The method according to claim 2, characterized in that The automatic detection of the Nginx configuration file based on the environment variable and the system variable includes: Automatically detect the first type of configuration items in the Nginx configuration files corresponding to the front-end base and the sub-application based on the environment variables and the system variables; Based on the environment variables and the system variables, the second type of configuration items in the Nginx configuration file corresponding to the front-end base are automatically detected.
4. The method according to claim 3, characterized in that The first category of configuration items includes: work process configuration, access log configuration, static resource compression configuration, cross-domain configuration, port occupation and port consistency; The second category of configuration items includes: gateway service configuration, port opening configuration, sub-application routing configuration and jump page configuration.
5. The method according to claim 1, characterized in that The automatic detection report of the Nginx configuration file is generated according to the automatic detection result, including: Generate report overview based on automated detection time, Cyber Range System environment variables, and Cyber Range System version; Obtaining the overall status of each of the configuration items in the automated detection, and generating a detection result summary based on the overall status; Obtaining the test results of each of the configuration items in the automated test, and generating detailed inspection results based on the test results; Determine the modification suggestion rectification plan according to the test results of each configuration item; Generate the Nginx configuration file automated detection report based on the report overview, the detection result overview, the detailed inspection results and the modification suggestion rectification plan.
6. The method according to claim 1, characterized in that After generating the Nginx configuration file automatic detection report according to the automatic detection result, the method further includes: The automated detection report is reviewed, and when it is determined that the review is passed, the network range system is started.
7. A verification device for Nginx configuration of a network range system, characterized in that: include: The detection script startup module is used to start the Nginx configuration automatic detection script when receiving the Nginx configuration detection instruction; An environment variable and system variable acquisition module, used to acquire the environment variables of the network range system and the system variables of the operating system through the Nginx configuration automatic detection script, wherein the network range system runs on the operating system; An automated detection module, configured to read an Nginx configuration file loaded into the network range system through the Nginx configuration automated detection script, and to perform automated detection on the Nginx configuration file based on the environment variables and the system variables; The detection report generation module is used to generate an automated detection report for the Nginx configuration file based on the automated detection results; The device further comprises a configuration file writing module. The configuration file writing module is used to receive configuration writing instructions for the front-end base and sub-applications in the network target range system, wherein the front-end base is associated with each sub-application respectively; and create the Nginx configuration file for the front-end base and the sub-application according to the configuration writing instructions.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method according to any one of claims 1 to 6 when executed.
Citation Information
Patent Citations
Automatic testing method and system based on Nginx hot restart switching baffle environment
CN117271322A
Webpage access request processing method and device, storage medium and electronic equipment
CN117714155A