A structured and textual Nginx configuration system, method and device

CN117235404BActive Publication Date: 2026-06-09E SURFING VISION TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
E SURFING VISION TECHNOLOGY CO LTD
Filing Date
2023-10-27
Publication Date
2026-06-09

Smart Images

  • Figure CN117235404B_ABST
    Figure CN117235404B_ABST
Patent Text Reader

Abstract

The application discloses a structured and textual Nginx configuration system, method and device, which comprises a text-based configuration analysis module for generating structured configuration data based on configuration text; a configuration text content generation module for generating configuration text based on structured configuration data; and a real-time conversion module. The real-time conversion module is used for transmitting web configuration data to the configuration text content generation module through a web socket, generating configuration text based on the web configuration data by using the configuration text content generation module, transmitting web configuration text to the text-based configuration analysis module through a web socket, and generating structured configuration data based on the web configuration text by using the text-based configuration analysis module. The application supports structured and textual configuration methods, improves configuration efficiency, and meets the diversity of user requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of server configuration technology, and more specifically, to an Nginx configuration system, method, and apparatus that supports structured and text-based configuration. Background Technology

[0002] Nginx (Engine X) holds over 30% market share in the web server and reverse proxy server market within the internet industry, resulting in a massive amount of configuration required. In daily operations and maintenance, configuration is typically performed via command-line text or automated configuration management using scripts, which offer limited transparency and maintainability. Therefore, effective Nginx configuration management is a crucial requirement.

[0003] In Nginx configuration management, different users and scenarios may require different configuration methods. For example, structured configuration may be more intuitive and easier to use for users unfamiliar with command-line tools, while text-based configuration may be more efficient and flexible for users familiar with command-line tools. Furthermore, traditional text-based configuration requires users to manually edit configuration files, which is error-prone and inefficient. Therefore, how to cater to the diverse needs of users and improve configuration management efficiency has become a technical problem that needs to be solved. Summary of the Invention

[0004] In view of this, in order to achieve the above objectives, the first aspect of this application provides an Nginx configuration system that supports structured and textual configuration, including a textual configuration parsing module, a configuration text content generation module, and a real-time conversion module;

[0005] The text-based configuration parsing module is used to generate structured configuration data based on the configuration text.

[0006] The configuration text content generation module is used to generate configuration text based on structured configuration data;

[0007] The real-time conversion module is used to transmit web page configuration data to the configuration text content generation module via a web socket, and generate configuration text based on the web page configuration data using the configuration text content generation module; and to transmit the web page configuration text to the text-based configuration parsing module via a web socket, and generate structured configuration data based on the web page configuration text using the text-based configuration parsing module.

[0008] Preferably, the process by which the text-based configuration parsing module generates structured configuration data based on the configuration text includes:

[0009] Based on preset configuration fields and regular expressions, the configuration text is parsed to obtain each configuration block and the key field configuration of each configuration block;

[0010] Structured configuration data is generated based on each configuration block and the key fields configured in the configuration block.

[0011] Preferably, the process of parsing the configuration text based on preset configuration fields and regular expressions to obtain each configuration block and the key field configuration of each configuration block includes:

[0012] Scan each character in the configuration text and obtain each configuration block based on preset configuration fields and regular expressions;

[0013] Use regular expressions to extract the key field configurations of each configuration block.

[0014] Preferably, the text-based configuration parsing module is further configured to record the structured configuration data in a database in JSON format.

[0015] Preferably, the process by which the configuration text content generation module generates configuration text based on structured configuration data includes:

[0016] Iterate through each configuration item in the structured configuration data and convert each configuration item into a text command;

[0017] Each text command is arranged according to the Nginx configuration syntax to obtain the configuration text.

[0018] Preferably, the configuration text content generation module is further configured to save the configuration text to a configuration file and generate configuration data with the configuration file as the key and the configuration text as the value, wherein the configuration data is in JSON format.

[0019] The second aspect of this application provides a method for configuring Nginx that supports both structured and text-based methods, including:

[0020] Upon receiving a user's modification request, the system determines whether the configuration mode is text-based or structured based on the modification request.

[0021] If the configuration mode is text-based, the webpage configuration text is obtained based on the content of the configuration page, and the real-time conversion module generates structured configuration data based on the webpage configuration text, and the structured configuration data is updated to the target database.

[0022] If the configuration mode is structured mode, obtain the web page configuration data based on the content in the configuration page, and update the web page configuration data to the target database;

[0023] The real-time conversion module generates configuration text based on the configuration data in the target database, and updates the target configuration file with the configuration text;

[0024] The real-time conversion module comes from the aforementioned Nginx configuration system.

[0025] Preferably, the Nginx configuration method supporting structured and textual formats further includes:

[0026] Upon receiving a user's mode switching request, the system determines, based on the mode switching instruction, whether the switching direction is from text mode to structured mode or from structured mode to text mode.

[0027] If the switching direction is from text mode to structured mode, the real-time conversion module generates structured configuration data and displays the structured configuration data on the page;

[0028] If the switching direction is from structured mode to text mode, the real-time conversion module generates configuration text and displays the configuration text on the page.

[0029] Preferably, the Nginx configuration method supporting structured and textual formats further includes:

[0030] Each target configuration file is monitored in real time, and the target configuration file is reloaded on the page after a change is detected.

[0031] A third aspect of this application provides an Nginx configuration apparatus that supports structured and text-based configuration, including:

[0032] The configuration mode determination unit is used to determine whether the configuration mode is text mode or structured mode based on the modification request after receiving the user's modification request.

[0033] The text modification processing unit is used to obtain the webpage configuration text based on the content of the configuration page if the configuration mode is text mode, generate structured configuration data based on the webpage configuration text using the real-time conversion module, and update the structured configuration data to the target database.

[0034] The structured modification processing unit is used to obtain webpage configuration data based on the content of the configuration page and update the webpage configuration data to the target database if the configuration mode is structured mode.

[0035] The configuration file synchronization unit is used to generate configuration text based on configuration data in the target database using the real-time conversion module, and update the configuration text to the target configuration file;

[0036] The real-time conversion module comes from the aforementioned Nginx configuration system.

[0037] A fourth aspect of this application provides an Nginx configuration device that supports structured and text-based configuration, including: a memory and a processor;

[0038] The memory is used to store programs;

[0039] The processor is used to execute the program to implement the various steps of the above-described Nginx configuration method that supports structured and textual configuration.

[0040] The fifth aspect of this application provides a storage medium on which a computer program is stored, which, when executed by a processor, implements the steps of the above-described Nginx configuration method that supports structured and textual representations.

[0041] As described above, this application includes a text-based configuration parsing module, a configuration text content generation module, and a real-time conversion module. The text-based configuration parsing module generates structured configuration data based on the configuration text; the configuration text content generation module generates configuration text based on the structured configuration data. The configuration text is text written using Nginx configuration syntax, and each configuration text corresponds to a configuration file in the Nginx server configuration file directory. The structured configuration data records the content of each configuration item in the Nginx configuration in key-value format, and also records the hierarchical relationship between the configuration items. This data can be intuitively displayed on the page in a graphical form, avoiding errors that may occur during manual editing. Through the hierarchical relationship of the configuration items, users can quickly find and modify the required configuration items, improving the maintainability of the configuration. The real-time conversion module is used to transmit webpage configuration data to the configuration text content generation module via a web socket, and generate configuration text based on the webpage configuration data using the configuration text content generation module; and to transmit the webpage configuration text to the text-based configuration parsing module via a web socket, and generate structured configuration data based on the text-based configuration text using the text-based configuration parsing module. This real-time conversion mode allows users to seamlessly switch between different configuration modes in real time on the page, meeting diverse user needs. Attached Figure Description

[0042] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0043] Figure 1 This is a schematic diagram of the Nginx configuration system supporting structured and text-based configuration disclosed in an embodiment of this application;

[0044] Figure 2 This is a schematic diagram illustrating the Nginx configuration method supporting structured and textual formats disclosed in an embodiment of this application;

[0045] Figure 3 This is a schematic diagram of the mode switching method disclosed in the embodiments of this application;

[0046] Figure 4 This is a schematic diagram of the Nginx configuration device supporting structured and textual processing disclosed in an embodiment of this application;

[0047] Figure 5 This is a schematic diagram of an Nginx configuration device that supports structured and textual configuration, as disclosed in an embodiment of this application. Detailed Implementation

[0048] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0049] The following describes an Nginx configuration system supporting structured and text-based configuration provided in an embodiment of this application. Please refer to [link / reference]. Figure 1 The Nginx configuration system supporting structured and textual configuration provided in this application embodiment may include a textual configuration parsing module 10, a configuration text content generation module 20, and a real-time conversion module 50.

[0050] The text-based configuration parsing module 10 is used to generate structured configuration data based on the configuration text; the configuration text content generation module 20 is used to generate configuration text based on the structured configuration data.

[0051] Specifically, the configuration text is the configuration content written in plain text. Typically, users can manually edit the configuration text via the command line.

[0052] Structured configuration data records each configuration item in key-value pairs, along with the hierarchical relationships between them. This structured data can be presented graphically, allowing users to quickly find the required configuration items. Compared to configuration text, it requires less manual input, is less prone to errors, and improves configuration efficiency.

[0053] The real-time conversion module 50 is used to transmit web page configuration data to the configuration text content generation module 20 via Web Socket, and generate configuration text based on the web page configuration data using the configuration text content generation module 20; and to transmit the web page configuration text to the text-based configuration parsing module 10 via Web Socket, and generate structured configuration data based on the web page configuration text using the text-based configuration parsing module 10.

[0054] This application includes a text-based configuration parsing module, a configuration text content generation module, and a real-time conversion module. The text-based configuration parsing module generates structured configuration data based on the configuration text; the configuration text content generation module generates configuration text based on the structured configuration data. The configuration text is written using Nginx configuration syntax, and each configuration text corresponds to a configuration file in the Nginx server configuration file directory. The structured configuration data records the content of each configuration item in the Nginx configuration in key-value format, and also records the hierarchical relationship between the configuration items. This data can be intuitively displayed on the page in a graphical form, avoiding errors that may occur during manual editing. The hierarchical relationship between the configuration items allows users to quickly find and modify the required configuration items, improving the maintainability of the configuration. The real-time conversion module transmits web configuration data to the configuration text content generation module via a web socket, and uses the configuration text content generation module to generate configuration text based on the web configuration data. It also transmits the web configuration text to the text-based configuration parsing module via a web socket, and uses the text-based configuration parsing module to generate structured configuration data based on the web configuration text. The real-time switching mode allows users to seamlessly switch between different configuration modes in real time on the page, satisfying the diversity of user needs.

[0055] In some embodiments of this application, the process by which the text-based configuration parsing module 10 generates structured configuration data based on configuration text may include:

[0056] S1. Based on preset configuration fields and regular expressions, the configuration text is parsed to obtain each configuration block and the key field configuration of each configuration block.

[0057] Each configuration block can include a server block, an upstream block, a location block, etc.

[0058] S2, based on each configuration block and the key field configuration of the configuration block, generate structured configuration data.

[0059] For example, the key field of the server block is the server_name field, and the key field of the location block is the proxy_pass field.

[0060] In some embodiments of this application, the process of S2, which parses the configuration text based on preset configuration fields and regular expressions to obtain each configuration block and the key field configuration of each configuration block, may include:

[0061] S21, scan each character in the configuration text, and obtain each configuration block based on preset configuration fields and regular expressions.

[0062] S22, use regular expressions to obtain the key field configurations of each configuration block.

[0063] It should be noted that before S21, the contents of the configuration text have been read and converted into JSON data in JSON format.

[0064] For example, assuming you need to obtain the upstream block, the specific steps may include:

[0065] a1, with the configuration field "upstream", has the following regular expression:

[0066]

#*[\s\t]*\bupstream\b[\s\t]+(.*)[\s\t]*{

[0067] a2. Using the regular expression above to traverse the JSON data, we can read the content of the ellipsis in "upstream{…}" and the name of upstream.

[0068] a3 uses a preset regular expression to match the content read above and obtain the scheduling algorithm.

[0069] For example, the scheduling algorithm may include ip_hash, session_sticky, sticky, rr, wrr, url_hash, etc. Taking ip_hash as an example, the regular expression can be

[\s\t]*(\bip_hash\b)[\s\t]*;

[0070] Using the regular expression

[\s\t]*server[\s\t]+(.*?)([\s\t]+(.*))? ;

[0071] a5, the system creates or updates upstream host data based on the database storage situation.

[0072] a6 returns all upstream structured configuration content.

[0073] For example, assuming it is necessary to obtain the server block, the specific steps may include:

[0074] b1, the configuration field is "server", and the regular expression is:

[0075]

(^server\b|#*[\s\t]+server\b)[\s\t]*{

[0076] b2. Using the regular expression above to traverse the JSON data, the content of the ellipsis in "server{…}" can be read.

[0077] b3 uses the regular expression

[\s\t]*server_name[\s\t]+(.*?(.*?\r?\n?)+.*?);

[0078] b4 uses the regular expression

[\s\t]*listen[\s\t]+(\d{2,5})[\s\t]*(.*?);

[0079] b5 uses the regular expression

[\s\t]*listen[\s\t]+\[::]:(\d{2,5})[\s\t]*(.*?)*[\s\t]*;

[0080] b6 returns all server structured configuration content.

[0081] For example, assuming the location block needs to be retrieved, the following steps would be performed after the server block has been retrieved:

[0082] c1, with the configuration field "location", uses the following regular expression:

[0083]

#*[\s\t]*\blocation\b[\s\t]+(.*)[\s\t]*{

[0084] c2 uses the regular expression above to iterate through the JSON data, and can read the content of the ellipsis in "location{…}" and the path of the location.

[0085] c3 uses the regular expression

proxy_pass[\s\t]+(https?): / / (.*?)( / )? ;

[0086] c4 uses the regular expression `uwsgi_pass[\s\t]+(.*);` to obtain `proxy_pass` and other parameters.

[0087] c5, the remaining characters are additional configurations for the location.

[0088] For example, suppose you need to retrieve the remaining Key-Value parameters in the server block, you can perform the following steps:

[0089] d1. Use the following regular expression to match configuration blocks containing curly braces "{}" and replace them with empty strings:

[0090]

【[\s\t]*\r? \n? [\s\t]*.*[\s\t]*\r? \n? [\s\t]*}]

[0091] d2, in the remaining characters, use the following regular expression to match the key-value parameters:

[0092]

[\s\t]*[a-zA-Z0-9_]+[\s\t]+(.+[\s\t]*)+;[\s\t]*\r? \n? [\s\t]*

[0093] In some embodiments of this application, the text configuration parsing module 10 is further configured to record the structured configuration data in JSON format into a database.

[0094] By saving the converted structured configuration data to a database, it becomes easier to view, modify, and manage it.

[0095] In some embodiments of this application, the process by which the configuration text content generation module 20 generates configuration text based on structured configuration data may include:

[0096] S1, traverse each configuration item in the structured configuration data and convert each configuration item into a text command.

[0097] S2 arranges each text command according to the Nginx configuration syntax to obtain the configuration text.

[0098] Specifically, the converted text commands are formatted and organized according to the Nginx configuration file format to ensure the correct order and hierarchy of commands.

[0099] In some embodiments of this application, the configuration text content generation module 20 is further configured to save the configuration text to a configuration file and generate configuration data with the configuration file as the key and the configuration text as the value.

[0100] The configuration data is in JSON format.

[0101] The following describes an Nginx configuration method supporting structured and text-based configuration provided in embodiments of this application. This Nginx configuration method is built upon the Nginx configuration system described in the above embodiments. Please refer to... Figure 2 The Nginx configuration method supporting structured and text-based configuration provided in this application embodiment may include the following steps:

[0102] After receiving the user's modification request:

[0103] Step S101: Determine whether the configuration mode is text-based or structured.

[0104] Specifically, based on the modification request, it is determined whether the configuration mode is text-based or structured. If the configuration mode is text-based, step S102 is executed; if the configuration mode is structured, step S104 is executed.

[0105] Step S102: Obtain the webpage configuration text based on the content in the configuration page.

[0106] Step S103: Use the real-time conversion module to generate structured configuration data based on the webpage configuration text. Proceed to step S105.

[0107] Step S104: Obtain webpage configuration data based on the content in the configuration page.

[0108] The webpage configuration data is structured configuration data.

[0109] Step S105: Update the structured configuration data to the target database.

[0110] Step S106: The real-time conversion module generates configuration text based on the configuration data in the target database, and updates the configuration text to the target configuration file.

[0111] The real-time conversion module is derived from the Nginx configuration system described in the above embodiments. It should be noted that regardless of the configuration mode used, the corresponding configuration files and database tables will be updated synchronously.

[0112] The described Nginx configuration method includes both a white-screen Nginx configuration process and a customary black-screen configuration process, thus meeting the diverse needs of users.

[0113] In some embodiments of this application, please refer to Figure 3 The Nginx configuration method may further include:

[0114] After receiving the user's mode switching request:

[0115] Step S201: Switch direction judgment.

[0116] Specifically, based on the mode switching instruction, it is determined whether the switching direction is from text mode to structured mode or from structured mode to text mode. If the switching direction is from text mode to structured mode, step S202 is executed; if the switching direction is from structured mode to text mode, step S204 is executed.

[0117] Step S202: Use the real-time conversion module to generate structured configuration data.

[0118] Step S203: Display the structured configuration data on the page.

[0119] Step S204: Use the real-time conversion module to generate configuration text.

[0120] Step S205: Display the configuration text on the page.

[0121] The above steps enable intelligent real-time conversion between text-based and structured configurations based on user page actions, avoiding repetitive user operations.

[0122] In some embodiments of this application, the Nginx configuration method may further include:

[0123] Each target configuration file is monitored in real time, and the target configuration file is reloaded on the page after a change is detected.

[0124] The following describes the Nginx configuration device that supports structured and textual configuration provided in the embodiments of this application. The Nginx configuration device that supports structured and textual configuration described below can be referred to in correspondence with the Nginx configuration method that supports structured and textual configuration described above.

[0125] Please see Figure 4The Nginx configuration apparatus supporting structured and text-based configuration provided in this application embodiment may include:

[0126] The configuration mode determination unit 61 is used to determine whether the configuration mode is text mode or structured mode based on the modification request after receiving the user's modification request.

[0127] The text modification processing unit 62 is used to obtain the web page configuration text based on the content in the configuration page if the configuration mode is text mode, generate structured configuration data based on the web page configuration text using the real-time conversion module, and update the structured configuration data to the target database.

[0128] The structured modification processing unit 63 is used to obtain web page configuration data based on the content in the configuration page and update the web page configuration data to the target database if the configuration mode is structured mode.

[0129] The configuration file synchronization unit 64 is used to generate configuration text based on configuration data in the target database using the real-time conversion module, and update the configuration text to the target configuration file;

[0130] The real-time conversion module is derived from the Nginx configuration system in the above embodiments.

[0131] In some embodiments of this application, the Nginx configuration device may further include a mode switching unit, the mode switching unit being used for:

[0132] Upon receiving a user's mode switching request, the system determines, based on the mode switching instruction, whether the switching direction is from text mode to structured mode or from structured mode to text mode.

[0133] If the switching direction is from text mode to structured mode, the real-time conversion module generates structured configuration data and displays the structured configuration data on the page;

[0134] If the switching direction is from structured mode to text mode, the real-time conversion module generates configuration text and displays the configuration text on the page.

[0135] In some embodiments of this application, the Nginx configuration device may further include a file monitoring unit, the file monitoring unit being used for:

[0136] Each target configuration file is monitored in real time, and the target configuration file is reloaded on the page after a change is detected.

[0137] The Nginx configuration device supporting structured and text-based configuration provided in this application embodiment can be applied to Nginx configuration devices that support structured and text-based configuration, such as computers. Optionally, Figure 5 This diagram shows the hardware architecture of an Nginx configuration device that supports structured and text-based configuration. Figure 5 The hardware structure of an Nginx configuration device that supports structured and textual configuration may include: at least one processor 31, at least one communication interface 32, at least one memory 33, and at least one communication bus 34.

[0138] In this embodiment, the number of processor 31, communication interface 32, memory 33 and communication bus 34 is at least one, and processor 31, communication interface 32 and memory 33 communicate with each other through communication bus 34;

[0139] The processor 31 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.

[0140] The memory 33 may include high-speed RAM, and may also include non-volatile memory, such as at least one disk storage device;

[0141] The memory 33 stores a program, and the processor 31 can call the program stored in the memory 33. The program is used for:

[0142] Upon receiving a user's modification request, the system determines whether the configuration mode is text-based or structured based on the modification request.

[0143] If the configuration mode is text-based, the web page configuration text is obtained based on the content of the configuration page, the web page configuration text is updated to the target configuration file, and the real-time conversion module generates structured configuration data based on the web page configuration text, and the structured configuration data is updated to the target database.

[0144] If the configuration mode is structured mode, obtain web page configuration data based on the content in the configuration page, update the web page configuration data to the target database, and use the real-time conversion module to generate configuration text based on the web page configuration data, and update the configuration text to the target configuration file.

[0145] The real-time conversion module is derived from the Nginx configuration system in the above embodiments.

[0146] Optionally, the refined and extended functions of the program can be found in the description above.

[0147] This application embodiment also provides a storage medium that can store a program suitable for execution by a processor, the program being used for:

[0148] Upon receiving a user's modification request, the system determines whether the configuration mode is text-based or structured based on the modification request.

[0149] If the configuration mode is text-based, the web page configuration text is obtained based on the content of the configuration page, the web page configuration text is updated to the target configuration file, and the real-time conversion module generates structured configuration data based on the web page configuration text, and the structured configuration data is updated to the target database.

[0150] If the configuration mode is structured mode, obtain web page configuration data based on the content in the configuration page, update the web page configuration data to the target database, and use the real-time conversion module to generate configuration text based on the web page configuration data, and update the configuration text to the target configuration file.

[0151] The real-time conversion module is derived from the Nginx configuration system in the above embodiments.

[0152] Optionally, the refined and extended functions of the program can be found in the description above.

[0153] In summary:

[0154] This application includes a text-based configuration parsing module, a configuration text content generation module, and a real-time conversion module. The text-based configuration parsing module generates structured configuration data based on the configuration text; the configuration text content generation module generates configuration text based on the structured configuration data. The configuration text is written using Nginx configuration syntax, and each configuration text corresponds to a configuration file in the Nginx server configuration file directory. The structured configuration data records the content of each configuration item in the Nginx configuration in key-value format, and also records the hierarchical relationship between the configuration items. This data can be intuitively displayed on the page in a graphical form, avoiding errors that may occur during manual editing. The hierarchical relationship between the configuration items allows users to quickly find and modify the required configuration items, improving the maintainability of the configuration. The real-time conversion module transmits web configuration data to the configuration text content generation module via a web socket, and uses the configuration text content generation module to generate configuration text based on the web configuration data. It also transmits the web configuration text to the text-based configuration parsing module via a web socket, and uses the text-based configuration parsing module to generate structured configuration data based on the web configuration text. The real-time switching mode allows users to seamlessly switch between different configuration modes in real time on the page, satisfying the diversity of user needs.

[0155] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, 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 limitations, 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.

[0156] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.

[0157] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. An Nginx configuration system that supports structured and text-based configuration, characterized in that, It includes a text-based configuration parsing module, a configuration text content generation module, and a real-time conversion module; The text-based configuration parsing module is used to generate structured configuration data based on the configuration text. The configuration text content generation module is used to generate configuration text based on structured configuration data; The real-time conversion module is used to transmit web page configuration data to the configuration text content generation module via a web socket, and generate configuration text based on the web page configuration data using the configuration text content generation module; and to transmit the web page configuration text to the text-based configuration parsing module via a web socket, and generate structured configuration data based on the web page configuration text using the text-based configuration parsing module. The Nginx configuration method of the Nginx configuration system includes: Upon receiving a user's modification request, the system determines whether the configuration mode is text-based or structured based on the modification request. If the configuration mode is text-based, the webpage configuration text is obtained based on the content of the configuration page, and the real-time conversion module generates structured configuration data based on the webpage configuration text, and the structured configuration data is updated to the target database. If the configuration mode is structured mode, obtain the web page configuration data based on the content in the configuration page, and update the web page configuration data to the target database; The real-time conversion module generates configuration text based on the configuration data in the target database and updates the configuration text to the target configuration file.

2. The Nginx configuration system according to claim 1, characterized in that, The process by which the text-based configuration parsing module generates structured configuration data based on the configuration text includes: Based on preset configuration fields and regular expressions, the configuration text is parsed to obtain each configuration block and the key field configuration of each configuration block; Structured configuration data is generated based on each configuration block and the key fields configured in the configuration block.

3. The Nginx configuration system according to claim 2, characterized in that, The process of parsing the configuration text based on preset configuration fields and regular expressions to obtain each configuration block and the key field configuration of each configuration block includes: Scan each character in the configuration text and obtain each configuration block based on preset configuration fields and regular expressions; Use regular expressions to extract the key field configurations of each configuration block.

4. The Nginx configuration system according to claim 2, characterized in that, The text-based configuration parsing module is also used to record the structured configuration data in JSON format into the database.

5. The Nginx configuration system according to claim 1, characterized in that, The configuration text content generation module generates configuration text based on structured configuration data, including the following process: Iterate through each configuration item in the structured configuration data and convert each configuration item into a text command; Each text command is arranged according to the Nginx configuration syntax to obtain the configuration text.

6. The Nginx configuration system according to claim 5, characterized in that, The configuration text content generation module is also used to save the configuration text to a configuration file and generate configuration data with the configuration file as the key and the configuration text as the value, wherein the configuration data is in JSON format.

7. An Nginx configuration method that supports structured and text-based configurations, characterized in that, include: Upon receiving a user's modification request, the system determines whether the configuration mode is text-based or structured based on the modification request. If the configuration mode is text-based, the webpage configuration text is obtained based on the content of the configuration page, and the real-time conversion module generates structured configuration data based on the webpage configuration text, and the structured configuration data is updated to the target database. If the configuration mode is structured mode, obtain the web page configuration data based on the content in the configuration page, and update the web page configuration data to the target database; The real-time conversion module generates configuration text based on the configuration data in the target database, and updates the target configuration file with the configuration text; The real-time conversion module is derived from the Nginx configuration system described in any one of claims 1 to 6.

8. The Nginx configuration method according to claim 7, characterized in that, Also includes: Upon receiving a user's mode switching request, the system determines, based on the mode switching instruction, whether the switching direction is from text mode to structured mode or from structured mode to text mode. If the switching direction is from text mode to structured mode, the real-time conversion module generates structured configuration data and displays the structured configuration data on the page; If the switching direction is from structured mode to text mode, the real-time conversion module generates configuration text and displays the configuration text on the page.

9. The Nginx configuration method according to claim 7, characterized in that, Also includes: Each target configuration file is monitored in real time, and the target configuration file is reloaded on the page after a change is detected.

10. An Nginx configuration device that supports structured and text-based configuration, characterized in that, include: The configuration mode determination unit is used to determine whether the configuration mode is text mode or structured mode based on the modification request after receiving the user's modification request. The text modification processing unit is used to obtain the webpage configuration text based on the content of the configuration page if the configuration mode is text mode, generate structured configuration data based on the webpage configuration text using the real-time conversion module, and update the structured configuration data to the target database. The structured modification processing unit is used to obtain webpage configuration data based on the content of the configuration page and update the webpage configuration data to the target database if the configuration mode is structured mode. The configuration file synchronization unit is used to generate configuration text based on configuration data in the target database using the real-time conversion module, and update the configuration text to the target configuration file; The real-time conversion module is derived from the Nginx configuration system described in any one of claims 1 to 6.