A method, device and storage medium for automatically generating an Nginx configuration file

CN116827789BActive Publication Date: 2026-08-18INSPUR GENERSOFT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310783155.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-29
Publication Date
2026-08-18
Estimated Expiration
2043-06-29

AI Technical Summary

Technical Problem

[0004]本申请实施例提供了一种Nginx配置文件的自动生成方法、设备及存储介质,用以解决如下技术问题:在生成或修改Nginx配置文件的过程中,无法快速准确的进行配置,容易导致Nginx功能缺失

Benefits of technology

[0015] This application provides an automatic generation method, device, and storage medium for Nginx configuration files. While ensuring the stable operation of business applications, it enables accurate and rapid generation of Nginx configuration files. It also ensures the stable operation of Nginx applications and allows for quick, simple, and accurate modification of Nginx configuration files. This provides accuracy and security in configuration, facilitating development, debugging, and deployment for developers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116827789B_ABST
    Figure CN116827789B_ABST
Patent Text Reader

Abstract

The application discloses an automatic generation method and device of an Nginx configuration file and a storage medium, and aims at solving the technical problem that the configuration cannot be quickly and accurately performed in the process of generating or modifying the Nginx configuration file, and the Nginx function is easily lost. The method comprises the following steps: obtaining an Nginx configuration file to be operated, and performing analysis on the Nginx configuration file to be operated to obtain configuration information of the Nginx configuration file to be operated; a front-end program pulls static resource information and an html page of Nginx, and judges whether the configuration information contains the static resource information and the html page of Nginx; in the case that the configuration information does not contain the static resource information or the html page of Nginx, generating updated Nginx configuration information; based on the updated Nginx configuration information, generating an updated Nginx configuration file, and running the updated Nginx configuration file. The application can accurately and quickly generate the Nginx configuration file under the condition of ensuring the stable operation of a business application program.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, device and storage medium for automatically generating Nginx configuration files. Background Technology

[0002] Nginx is a lightweight internet server / reverse proxy server and email proxy server that focuses on high performance, high concurrency, and low memory consumption, making it well-suited for modern website architectures. Nginx supports hot deployment. It is exceptionally easy to start and can run almost 24 / 7 without interruption, even for months without requiring a restart. It also allows for software version upgrades without interrupting service.

[0003] As a high-performance reverse proxy web server, Nginx provides IAMP / POP3 / SMTP services. When Nginx offers one or more of these services, its configuration file can be complex. Modifying the configuration file using traditional file editing methods is labor-intensive, error-prone, time-consuming, and inefficient. Incorrect configuration can disrupt normal business operations and cause losses. Summary of the Invention

[0004] This application provides an automatic generation method, device, and storage medium for Nginx configuration files to solve the following technical problem: during the generation or modification of Nginx configuration files, it is impossible to configure quickly and accurately, which can easily lead to the loss of Nginx functionality.

[0005] In a first aspect, embodiments of this application provide an automatic generation method for Nginx configuration files, characterized in that the method includes: obtaining an Nginx configuration file to be operated on, and parsing the Nginx configuration file to be operated on to obtain configuration information of the Nginx configuration file to be operated on; a front-end program pulls static resource information and HTML pages of Nginx, and determines whether the configuration information contains static resource information and HTML pages of Nginx; if the configuration information contains static resource information or HTML pages of Nginx that are not included, generating Nginx configuration information to be updated; generating an Nginx configuration file to be updated based on the Nginx configuration information to be updated, and running the Nginx configuration file to be updated.

[0006] In one implementation of this application, obtaining the Nginx configuration file to be operated specifically includes: generating an initialized Nginx configuration file to be operated based on a preset Nginx configuration file generation rule; and uploading the Nginx configuration file to be operated to a preset storage directory to obtain the Nginx configuration file to be operated.

[0007] In one implementation of this application, the Nginx configuration file to be operated is parsed to obtain its configuration information. Specifically, this includes: reading the Nginx configuration file to be operated to obtain its text information; and processing the text information based on a preset natural language processing algorithm to determine the configuration information of the Nginx configuration file to be operated.

[0008] In one implementation of this application, after parsing the Nginx configuration file to be operated to obtain its configuration information, the method further includes: determining whether the configuration information of the Nginx configuration file to be operated contains nginx port information and service name information; if it is determined that the configuration information of the Nginx configuration file to be operated contains nginx port information and service name information, then determining that the information containing nginx port information and service name information is operable configuration information; if it is determined that the configuration information of the Nginx configuration file to be operated contains either nginx port information or service name information, then determining that the information containing nginx port information and service name information is inoperable configuration information, and ending the generation process.

[0009] In one implementation of this application, after the front-end program retrieves the static resource information and HTML page from Nginx, the method further includes: converting the static resource information and HTML page into key-value information, and sending the converted key-value information to a preset resource information list; the front-end program displays the resource information list and configures an editable function module for the resource information list.

[0010] In one implementation of this application, after the front-end program displays the resource information list and configures the editable function module for the resource information list, the method further includes: according to the preset requirements of the Nginx configuration file to be updated, editing the resource information list through the editable function module to obtain an updated resource information list; wherein, the editing process includes: adding, deleting, and modifying.

[0011] In one implementation of this application, generating the Nginx configuration information to be updated specifically includes: parsing the key-value information of the updated resource information list based on a natural language processing algorithm, and converting the format of the key-value information of the updated resource information list to generate the Nginx configuration information to be updated.

[0012] In one implementation of this application, running the Nginx configuration file to be updated specifically includes: responding to the Nginx configuration activation request instruction, hot-starting Nginx to activate the Nginx configuration file to be updated.

[0013] Secondly, embodiments of this application also provide an automatic Nginx configuration file generation device, characterized in that the device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: obtain an Nginx configuration file to be operated, and parse the Nginx configuration file to be operated to obtain configuration information of the Nginx configuration file to be operated; a front-end program pulls Nginx static resource information and HTML pages, and determines whether the configuration information contains Nginx static resource information and HTML pages; if the configuration information contains Nginx static resource information or HTML pages that are not included, generate Nginx configuration information to be updated; based on the Nginx configuration information to be updated, generate an Nginx configuration file to be updated, and run the Nginx configuration file to be updated.

[0014] Thirdly, embodiments of this application also provide a non-volatile computer storage medium for automatically generating Nginx configuration files, storing computer-executable instructions, characterized in that the computer-executable instructions are configured to: obtain the Nginx configuration file to be operated, and parse the Nginx configuration file to be operated to obtain the configuration information of the Nginx configuration file to be operated; a front-end program pulls the static resource information and HTML page of Nginx, and determines whether the configuration information contains the static resource information and HTML page of Nginx; if the configuration information contains Nginx static resource information or HTML page that is not included, generate Nginx configuration information to be updated; based on the Nginx configuration information to be updated, generate the Nginx configuration file to be updated, and run the Nginx configuration file to be updated.

[0015] This application provides an automatic generation method, device, and storage medium for Nginx configuration files. While ensuring the stable operation of business applications, it enables accurate and rapid generation of Nginx configuration files. It also ensures the stable operation of Nginx applications and allows for quick, simple, and accurate modification of Nginx configuration files. This provides accuracy and security in configuration, facilitating development, debugging, and deployment for developers. Attached Figure Description

[0016] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments of this application and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0017] Figure 1 A flowchart illustrating an automatic Nginx configuration file generation method provided in this application embodiment;

[0018] Figure 2 This is a schematic diagram of the internal structure of a device for automatically generating Nginx configuration files, provided as an embodiment of this application. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0020] This application provides an automatic generation method, device, and storage medium for Nginx configuration files to solve the following technical problem: during the generation or modification of Nginx configuration files, it is impossible to configure quickly and accurately, which can easily lead to the loss of Nginx functionality.

[0021] The technical solutions proposed in the embodiments of this application will be described in detail below with reference to the accompanying drawings.

[0022] Figure 1 This document provides a flowchart of a method for automatically generating Nginx configuration files, as illustrated in an embodiment of this application. Figure 1 As shown in the figure, the method for automatically generating Nginx configuration files provided in this application embodiment specifically includes the following steps:

[0023] Step 101: Obtain the Nginx configuration file to be operated on, and parse the Nginx configuration file to obtain the configuration information of the Nginx configuration file to be operated on.

[0024] It's important to note that the Nginx configuration file is a computer file that stores information needed to configure the Nginx program when it starts. Therefore, for routine maintenance, it's necessary to obtain the Nginx configuration file and initialize and update the configuration data within it. Because Nginx configuration files are not in Extensible Markup Language (XML) format—meaning they have an irregular format—parsing and manipulating them is relatively difficult. To improve the efficiency and accuracy of routine maintenance, it's necessary to enhance the convenience and accuracy of parsing and manipulating Nginx configuration files.

[0025] In one embodiment of this application, obtaining the Nginx configuration file to be operated specifically includes: generating an initialized Nginx configuration file to be operated based on a preset Nginx configuration file generation rule; and uploading the Nginx configuration file to be operated to a preset storage directory to obtain the Nginx configuration file to be operated.

[0026] It should be noted that the Nginx configuration file to be operated in this application can be an empty file without any content.

[0027] Furthermore, the Nginx configuration file to be operated on is parsed to obtain its configuration information.

[0028] Specifically, the Nginx configuration file to be operated is read to obtain its text information; the text information is then processed based on a preset natural language processing algorithm to determine the configuration information of the Nginx configuration file to be operated.

[0029] Step 102: The front-end program fetches the static resource information and HTML page of Nginx, and determines whether the configuration information includes the static resource information and HTML page of Nginx.

[0030] In one embodiment of this application, after parsing the Nginx configuration file to be operated to obtain its configuration information, it is determined whether the configuration information of the Nginx configuration file to be operated contains nginx port information and service name information. If it is determined that the configuration information of the Nginx configuration file to be operated contains nginx port information and service name information, it is determined that the information containing nginx port information and service name information is operable configuration information. If it is determined that the configuration information of the Nginx configuration file to be operated contains either nginx port information or service name information, it is determined that the information containing nginx port information and service name information is inoperable configuration information, and the generation process ends.

[0031] In one embodiment of this application, if it is determined that the configuration information of the Nginx configuration file to be operated contains nginx port information and service name information, the front-end program pulls the static resource information and HTML pages of Nginx in the pre-approval file directory.

[0032] In one embodiment of this application, after the front-end program retrieves the static resource information and HTML page from Nginx, the method further includes: converting the static resource information and HTML page into key-value information, and sending the converted key-value information to a preset resource information list; the front-end program displays the resource information list and configures an editable function module for the resource information list.

[0033] In one embodiment of this application, after the front-end program displays the resource information list and configures the resource information list with an editable function module, the method further includes: according to the preset requirements of the Nginx configuration file to be updated, editing the resource information list through the editable function module to obtain an updated resource information list; wherein, the editing process includes: adding, deleting, and modifying.

[0034] Furthermore, based on the updated resource information list, determine whether the configuration information includes the updated Nginx static resource information and HTML pages.

[0035] Step 103: If the configuration information contains Nginx static resource information or HTML pages that are not included, generate the Nginx configuration information to be updated.

[0036] In one embodiment of this application, if the configuration information includes all updated Nginx static resource information and HTML pages, the Nginx configuration information to be updated is no longer generated.

[0037] In one embodiment of this application, if the configuration information contains Nginx static resource information or HTML pages that are not included, Nginx configuration information to be updated is generated.

[0038] Specifically, based on natural language processing algorithms, the key-value information of the updated resource information list is parsed, and the format of the key-value information of the updated resource information list is converted to generate the Nginx configuration information to be updated.

[0039] Step 104: Based on the Nginx configuration information to be updated, generate the Nginx configuration file to be updated and run the Nginx configuration file to be updated.

[0040] In one embodiment of this application, after generating the Nginx configuration information to be updated, the Nginx configuration information to be updated is encapsulated to obtain the Nginx configuration file to be updated.

[0041] Next, run the Nginx configuration file to be updated.

[0042] Specifically, in response to the Nginx configuration activation request command, Nginx is hot-started to apply the updated Nginx configuration file.

[0043] The above are embodiments of the method proposed in this application. Based on the same inventive concept, embodiments of this application also provide an automatic Nginx configuration file generation device, the structure of which is as follows: Figure 2 As shown.

[0044] Figure 2 This is a schematic diagram of the internal structure of a device for automatically generating Nginx configuration files, provided as an embodiment of this application. Figure 2 As shown, the device includes:

[0045] At least one processor 201;

[0046] And a memory 202 that is communicatively connected to at least one processor;

[0047] The memory 202 stores instructions executable by at least one processor, which are executed by at least one processor 201 to enable at least one processor 201 to:

[0048] Obtain the Nginx configuration file to be operated on, and parse the Nginx configuration file to obtain the configuration information of the Nginx configuration file to be operated on;

[0049] The front-end program fetches static resource information and HTML pages from Nginx and determines whether the configuration information includes static resource information and HTML pages from Nginx.

[0050] If the configuration information contains Nginx static resource information or HTML pages that are not included, generate the Nginx configuration information to be updated.

[0051] Based on the Nginx configuration information to be updated, generate the Nginx configuration file to be updated and run the Nginx configuration file to be updated.

[0052] Some embodiments of this application provide corresponding to Figure 1 A non-volatile computer storage medium for automatically generating Nginx configuration files, storing computer-executable instructions, wherein the computer-executable instructions are configured as follows:

[0053] Obtain the Nginx configuration file to be operated on, and parse the Nginx configuration file to obtain the configuration information of the Nginx configuration file to be operated on;

[0054] The front-end program fetches static resource information and HTML pages from Nginx and determines whether the configuration information includes static resource information and HTML pages from Nginx.

[0055] If the configuration information contains Nginx static resource information or HTML pages that are not included, generate the Nginx configuration information to be updated.

[0056] Based on the Nginx configuration information to be updated, generate the Nginx configuration file to be updated and run the Nginx configuration file to be updated.

[0057] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments for IoT devices and media are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0058] The systems, media, and methods provided in this application are one-to-one correspondences. Therefore, the systems and media also have similar beneficial technical effects as their corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the systems and media will not be repeated here.

[0059] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0060] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0061] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0062] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0063] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0064] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0065] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0066] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0067] The above description is merely an embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of this application should be included within the scope of the claims of this application.

Claims

1. A method for automatically generating Nginx configuration files, characterized in that, The method includes: Obtain the Nginx configuration file to be operated and parse the Nginx configuration file to obtain the configuration information of the Nginx configuration file to be operated; The front-end program fetches the static resource information and HTML page of Nginx, and determines whether the configuration information contains the static resource information and HTML page of Nginx. If the configuration information contains static resource information or HTML pages of Nginx that are not included, generate Nginx configuration information to be updated; Based on the Nginx configuration information to be updated, generate the Nginx configuration file to be updated and run the Nginx configuration file to be updated; The Nginx configuration file to be operated on is parsed to obtain its configuration information, specifically including: Read the Nginx configuration file to be operated on to obtain the text information of the Nginx configuration file to be operated on; Based on a preset natural language processing algorithm, the text information is processed to determine the configuration information of the Nginx configuration file to be operated; After parsing the Nginx configuration file to be operated to obtain its configuration information, the method further includes: Determine whether the configuration information in the Nginx configuration file to be operated contains nginx port information and service name information; If it is determined that the configuration information of the Nginx configuration file to be operated contains nginx port information and service name information, then the information containing nginx port information and service name information is determined to be operable configuration information. If it is determined that the configuration information in the Nginx configuration file to be operated contains nginx port information or service name information, then the information containing nginx port information and service name information is determined to be unoperable configuration information, and the generation process ends. After the front-end program fetches the static resource information and HTML page from Nginx, the method further includes: The static resource information and the HTML page are converted into key-value information, and the converted key-value information is sent to a preset resource information list. The front-end program displays the resource information list and configures editable functional modules for the resource information list; After the front-end program displays the resource information list and configures the resource information list with editable functional modules, the method further includes: Based on the preset requirements of the Nginx configuration file to be updated, the resource information list is edited through the editable function module to obtain an updated resource information list; wherein, the editing process includes: adding, deleting, and modifying. Generate Nginx configuration information to be updated, specifically including: Based on natural language processing algorithms, the key-value information of the updated resource information list is parsed, and the format of the key-value information of the updated resource information list is converted to generate the Nginx configuration information to be updated.

2. The method for automatically generating Nginx configuration files according to claim 1, characterized in that, Obtain the Nginx configuration file to be operated, specifically including: Based on the preset rules for generating Nginx configuration files to be operated, an initial Nginx configuration file to be operated is generated. Upload the Nginx configuration file to be operated to the preset storage directory to obtain the Nginx configuration file to be operated.

3. The method for automatically generating Nginx configuration files according to claim 1, characterized in that, Running the Nginx configuration file to be updated specifically includes: In response to the Nginx configuration activation request command, Nginx is warm-started to apply the Nginx configuration file to be updated.

4. An automatic Nginx configuration file generation device, characterized in that, The device includes: At least one processor; And, a memory communicatively connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform an automatic generation method for an Nginx configuration file as described in any one of claims 1-3.

5. A non-volatile computer storage medium for automatically generating Nginx configuration files, storing computer-executable instructions, characterized in that... When the computer-executable instructions are executed, they implement an automatic generation method for Nginx configuration files as described in any one of claims 1-3.

Citation Information

Patent Citations

  • Server configuration method and device, electronic equipment

    CN109347675A

  • Static resource request response method and device, computer equipment and storage medium

    CN115665249A