Automatic modification method and system for website access port and electronic equipment
By automatically modifying the Nginx access port, the problems of cumbersome operations and poor modification efficiency in the existing technology are solved, and the port is automatically modified and used normally, improving user experience and website access flexibility.
Patent Information
- Application Number
- CN202411344171.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-02-11
AI Technical Summary
The prior art is complicated to modify the Nginx access port, and may not be used normally after modification, resulting in poor modification efficiency.
Provides an automated modification method for website access ports. By receiving port configuration information sent by the front-end, it automatically updates Nginx's configuration file, and automatically restarts Nginx after modification, so that the modified port number takes effect.
It realizes automatic port modification, simplifies operational processes, improves modification efficiency, ensures that the port is used normally after modification, improves user experience, and improves website access flexibility.
Smart Images

Figure CN119420642A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication network technology, and in particular to a method, system and electronic device for automatically modifying a website access port. Background Art
[0002] At present, most websites are configured and accessed using Nginx. When the computer port is occupied, the access port can be modified to achieve the scope of the website. However, the existing Java software package (Java Archive, JAR) does not support Nginx very well, and it is not possible to change the Nginx access port in a friendly way.
[0003] The prior art generally searches for the Nginx configuration file manually, finds all the Nginx ports that need to be modified in the corresponding configuration file, and modifies them. However, there is a problem that the prior art may not be able to start after the modification.
[0004] The prior art is cumbersome to operate when modifying ports, and the port may not be used normally after modification, resulting in poor modification efficiency. Summary of the invention
[0005] The embodiments of the present application provide a method, system and electronic device for automatically modifying a website access port, so as to at least solve the problem of poor modification efficiency when modifying a port in the related art.
[0006] In a first aspect, an embodiment of the present application provides a method for automatically modifying a website access port, comprising:
[0007] In response to receiving a port acquisition request sent by the front end, obtaining a port number from the Nginx configuration file and sending the port number to the front end, so that the front end displays a port configuration interface based on the port number;
[0008] receiving port configuration information sent by the front end, the port configuration information being acquired by the front end based on the port configuration interface, updating the configuration file based on the port configuration information, and modifying the port number based on the updated configuration file;
[0009] Restart Nginx according to the preset configuration instructions to make the modified port number take effect.
[0010] In one embodiment, updating the configuration file includes:
[0011] All port numbers in the configuration file are modified to port numbers in the port configuration information according to a preset modification function.
[0012] In one embodiment, updating the configuration file includes:
[0013] Generate a port modification file according to the port configuration information, and replace the port related information in the configuration file with the content in the port modification file.
[0014] In one embodiment, if restarting Nginx fails, the method includes:
[0015] Determine the erroneous configuration information that has problems according to the operation result after the restart, and delete the erroneous configuration information in the configuration file; or
[0016] According to the preset instructions, terminate the Nginx process and restart the Nginx process.
[0017] In one embodiment, the method further comprises:
[0018] After the restart is successful, the modification result and the modified port number are sent to the front end, so that the front end can display them according to the modification result and the modified port number.
[0019] In one embodiment, the method further comprises:
[0020] The receiving front end sends login information in response to the user login instruction, and logs in to the website according to the login information so that the user can use various interfaces in the website, wherein the login information includes the IP address and the modified port number.
[0021] In a second aspect, an embodiment of the present application provides a system for automatically modifying a website access port, the system comprising:
[0022] Port configuration display module: used to display the configuration interface to the user so that the user can configure the port;
[0023] Port modification module: used to implement the automatic modification method of the website access port according to any one of claims 1 to 6.
[0024] In one embodiment, the system further comprises:
[0025] Modification result display module: used to display the modification results and the modified port number to remind the user that the modification is successful;
[0026] Login module: used to log in to the website based on the IP address and modified port number so that users can use the various interfaces in the website normally.
[0027] In a third aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for automatically modifying the website access port as described in the first aspect above is implemented.
[0028] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for automatically modifying a website access port as described in the first aspect above.
[0029] The embodiments of the present application provide a method, system and electronic device for automatically modifying a website access port, which have at least the following technical effects.
[0030] This application uses a simple and convenient visual interface for modifying ports. Users only need to operate in the port configuration interface. After receiving the user's port configuration information, this application automatically modifies the Nginx configuration file according to the port configuration information, and automatically restarts Nginx after the modification. It solves the problem of manually finding the configuration file when manually modifying the port, and manually modifying the port numbers of all target locations in the configuration file, which is time-consuming and laborious. In this way, the access port is automatically modified, which effectively solves the time-consuming and labor-intensive problems of the prior art. The overall operation is convenient and improves the user experience. And when the port is occupied, the access port is automatically modified to improve the flexibility of website access.
[0031] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0033] Figure 1 It is a flow chart of a method for automatically modifying a website access port according to an embodiment of the present application;
[0034] Figure 2 It is a structural block diagram of a system for automatically modifying website access ports provided according to an embodiment of the present application;
[0035] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0037] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.
[0038] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0039] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0040] In the first aspect, an embodiment of the present application provides a method for automatically modifying a website access port. The method provided by the present application is mainly implemented based on the JAVA and VUE2 technology stack. Figure 1is a flow chart of a method for automatically modifying a website access port according to an embodiment of the present application, such as Figure 1 As shown, the method includes:
[0041] Step S101, in response to receiving a port acquisition request sent by the front end, obtain the port number from the Nginx configuration file and send the port number to the front end, so that the front end displays a port configuration interface based on the port number.
[0042] Optionally, Nginx is a high-performance web server and reverse proxy server, which is widely used to process HTTP requests. Many forwarding ports are configured on Nginx. After receiving the port acquisition request sent by the front end, the back end obtains the configuration port number from the nginx.conf configuration file of Nginx through the port acquisition method and returns it to the front end. Among them, the front end obtains the port information from the back end through the Axios call interface. After obtaining the port information, the front end displays the port configuration interface through Vue for the user to modify the port number. Among them, the port configuration interface at least includes: a text box for filling in the new port number and a confirmation button.
[0043] In this way, it is simple and convenient to modify the port using a graphical interface. Users only need to set the port number in the port configuration interface, and the port can be automatically modified through subsequent methods. The overall operation is convenient and conducive to improving the user experience.
[0044] Step S102, receiving the port configuration information sent by the front end, the port configuration information is obtained by the front end based on the port configuration interface, updating the configuration file based on the port configuration information, and modifying the port number based on the updated configuration file.
[0045] Optionally, the front end returns the port configuration information to the back end through the Axios call interface, wherein the port configuration information is generated according to the user's settings in the port configuration interface. After receiving the port configuration information, the back end writes the port number in the port configuration information into the Nginx configuration file using the underlying IO stream method, and then modifies the port number at the target location according to the port number written in the configuration file. Among them, the target location is the same location as the port number obtained in step S101. When manually modifying the port, it is necessary to manually search the configuration file, and it is necessary to manually modify the port numbers of all target locations in the configuration file, which is time-consuming and labor-intensive. In this way, the access port is automatically modified, which effectively solves the time-consuming and labor-intensive problems of the prior art and improves the user experience.
[0046] In one example, updating the configuration file in step S102 includes: modifying all port numbers in the configuration file to the port numbers in the port configuration information according to a preset modification function. Optionally, all port numbers in the configuration file that are the same as the port numbers obtained in step S101 are modified to the port numbers in the port configuration information.
[0047] In one example, updating the configuration file in step S102 includes: generating a port modification file according to the port configuration information, and replacing the port related information in the configuration file with the content in the port modification file. Optionally, the portion of the port configuration file that configures the same port number as the port number obtained in step S101 is deleted, and is modified to the portion of the port modification file that configures the new port number. In the case where the port is not configured before the current port configuration, the portion of the port modification file that configures the new port number can be directly added to the configuration file.
[0048] Through the above two methods of updating the configuration files, the port can be automatically modified. The overall operation is convenient and conducive to improving the user experience.
[0049] Step S103, restart Nginx according to the preset configuration instructions to make the modified port number take effect.
[0050] Optionally, after modifying the port, you also need to restart Nginx for the modified port number to take effect. Restarting Nginx is to call the CMD command line according to the preset configuration instructions and execute the restart command of Nginx to restart Nginx, thereby realizing a complete method of automatically modifying the port. When manually modifying the port, you need to manually restart Nginx after manually modifying the configuration file. The automated modification method for the website access port provided in this application automatically calls the command line to restart Nginx, and automatically restarts after modifying the port. The user only needs to click OK after modifying the port in the port configuration interface, without any additional operations, to realize the automated modification of the port. The overall operation is convenient, which improves the user experience.
[0051] In one example, if restarting Nginx fails, the method further includes: determining the wrong configuration information that has problems according to the running result after the restart, deleting the wrong configuration information in the configuration file, or terminating the Nginx process according to a preset instruction, and restarting the Nginx process.
[0052] Optionally, when you restart Nginx, you may encounter a problem that it cannot start. In this case, there may be a problem with some configurations in the modified configuration file, or there may be a problem with the Nginx process. The failure to restart Nginx is basically caused by these two aspects. Therefore, you can solve the problem of Nginx restart failure by deleting the incorrect configuration in the configuration file, or terminating the Nginx process and restarting it.
[0053] In one example, the method further includes: after the restart is successful, sending the modification result and the modified port number to the front end for the front end to display according to the modification result and the modified port number. Optionally, after the modification is successful, the front end displays the modification result and the modified port number to remind the user that the modification is successful.
[0054] In one example, the method further includes: receiving login information sent by the front end in response to a user login instruction, logging into the website according to the login information, so that the user can use various interfaces in the website, and the login information includes an IP address and a modified port number. Optionally, after the user has modified the port number, the original port number can no longer display the web page. It is necessary to enter the IP and the new port number by yourself, open the web page, enter the username and password to log in to the website, and use the various functions of the website normally through the various interfaces of the website.
[0055] In this way, when the computer port is occupied, the access port can be automatically modified to access the website using the port you need, thereby improving the flexibility of website access.
[0056] In summary, the present application simply and conveniently uses a graphical interface to modify the port. The user only needs to click OK after modifying the port in the port configuration interface. The automatic modification of the port can be realized without any additional operations. After receiving the user's port configuration information, the present application automatically modifies the Nginx configuration file according to the port configuration information, and automatically restarts Nginx after the modification. It solves the problem of manually finding the configuration file when manually modifying the port, and manually modifying the port numbers of all target locations in the configuration file, which is time-consuming and laborious. In this way, the access port is automatically modified, which effectively solves the time-consuming and labor-intensive problems of the prior art, and the overall operation is convenient, which improves the user experience. And when the port is occupied, the access port is automatically modified to improve the flexibility of website access.
[0057] In a second aspect, the present application provides an automated modification system for a website access port. Figure 2 is a structural block diagram of an automatic modification system for website access ports provided according to an embodiment of the present application, such as Figure 2 As shown, the system includes:
[0058] The port configuration display module 100 is used to display a configuration interface to the user so that the user can configure the port. Optionally, the port configuration interface at least includes: a text box for filling in a new port number and a confirmation button.
[0059] Port modification module 200: used to implement the automatic modification method of the website access port of the first aspect.
[0060] In one example, the system further includes:
[0061] Modification result display module 300: used to display the modification result and the modified port number to remind the user that the modification is successful.
[0062] Login module 400: used to log in to the website according to the IP address and the modified port number, so that the user can use the various interfaces in the website normally. Optionally, the user enters the user name and password to log in to the website after opening the web page according to the IP address and the modified port number, and uses the various functions of the website normally through the various interfaces of the website.
[0063] In summary, the present application simply and conveniently uses a graphical interface to modify the port. The user only needs to click OK after modifying the port in the port configuration interface. The automatic modification of the port can be realized without any additional operations. After receiving the user's port configuration information, the present application automatically modifies the Nginx configuration file according to the port configuration information, and automatically restarts Nginx after the modification. It solves the problem of manually finding the configuration file when manually modifying the port, and manually modifying the port numbers of all target locations in the configuration file, which is time-consuming and laborious. In this way, the access port is automatically modified, which effectively solves the time-consuming and labor-intensive problems of the prior art, and the overall operation is convenient, which improves the user experience. And when the port is occupied, the access port is automatically modified to improve the flexibility of website access.
[0064] In a third aspect, an embodiment of the present application provides an electronic device, Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the method for automatically modifying the website access port provided in the first aspect is implemented. Figure 3 The electronic device 60 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0065] The electronic device 60 may be in the form of a general-purpose computing device, for example, it may be a server device. The components of the electronic device 60 may include but are not limited to: at least one processor 61, at least one memory 62, and a bus 63 connecting different system components (including the memory 62 and the processor 61).
[0066] The bus 63 includes a data bus, an address bus, and a control bus.
[0067] The memory 62 may include a volatile memory, such as a random access memory (RAM) 621 and / or a cache memory 622 , and may further include a read-only memory (ROM) 623 .
[0068] The memory 62 may also include a program / utility 625 having a set (at least one) of program modules 624, such program modules 624 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0069] The processor 61 executes various functional applications and data processing by running the computer programs stored in the memory 62, such as the automatic modification method of the website access port provided in the first aspect of the present application.
[0070] The electronic device 60 may also communicate with one or more external devices 64 (e.g., keyboards, pointing devices, etc.). Such communication may be performed via an input / output (I / O) interface 65. Furthermore, the model-generated device 60 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 66. As shown, the network adapter 66 communicates with other modules of the model-generated device 60 via a bus 63. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the model-generated device 60, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (RAID) systems, tape drives, and data backup storage systems.
[0071] It should be noted that although several units / modules or sub-units / modules of the electronic device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided into multiple units / modules to be embodied.
[0072] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a program stored thereon, and when the program is executed by a processor, the method for automatically modifying the website access port provided in the first aspect is implemented.
[0073] The readable storage medium may include but is not limited to: a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical storage device, a magnetic storage device or any suitable combination of the above.
[0074] In a possible implementation, the present invention can also be implemented in the form of a program product, which includes program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps of the method for automatically modifying the website access port provided in the first aspect.
[0075] The program code for executing the present invention may be written in any combination of one or more programming languages, and may be executed entirely on a user device, partially on a user device, as an independent software package, partially on a user device and partially on a remote device, or entirely on a remote device.
[0076] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0077] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for automatically modifying a website access port, characterized in that: The method comprises: In response to receiving a port acquisition request sent by the front end, obtaining a port number from the Nginx configuration file and sending the port number to the front end, so that the front end displays a port configuration interface based on the port number; receiving port configuration information sent by the front end, the port configuration information being acquired by the front end based on the port configuration interface, updating the configuration file based on the port configuration information, and modifying the port number based on the updated configuration file; Restart Nginx according to the preset configuration instructions to make the modified port number take effect.
2. The method for automatically modifying a website access port according to claim 1, characterized in that: The updating of the configuration file comprises: All port numbers in the configuration file are modified to port numbers in the port configuration information according to a preset modification function.
3. The method for automatically modifying a website access port according to claim 1, characterized in that: The updating of the configuration file comprises: Generate a port modification file according to the port configuration information, and replace the port related information in the configuration file with the content in the port modification file.
4. The method for automatically modifying a website access port according to claim 1, characterized in that: If restarting Nginx fails, the following methods can be used: Determine the erroneous configuration information that has problems according to the operation result after the restart, and delete the erroneous configuration information in the configuration file; or According to the preset instructions, terminate the Nginx process and restart the Nginx process.
5. The method for automatically modifying a website access port according to claim 1, characterized in that: The method further comprises: After the restart is successful, the modification result and the modified port number are sent to the front end, so that the front end can display them according to the modification result and the modified port number.
6. The method for automatically modifying a website access port according to claim 5, characterized in that: The method further comprises: The receiving front end sends login information in response to the user login instruction, and logs in to the website according to the login information so that the user can use various interfaces in the website, wherein the login information includes the IP address and the modified port number.
7. An automated modification system for website access ports, characterized in that: The system includes: Port configuration display module: used to display the configuration interface to the user so that the user can configure the port; Port modification module: used to implement the automatic modification method of the website access port according to any one of claims 1 to 6.
8. The automatic modification system for website access ports according to claim 7, characterized in that: The system further comprises: Modification result display module: used to display the modification results and the modified port number to remind the user that the modification is successful; Login module: used to log in to the website based on the IP address and modified port number so that users can use the various interfaces in the website normally.
9. An electronic device, characterized in that: include Memory, processor, and A computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for automatically modifying the website access port according to any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for automatically modifying a website access port according to any one of claims 1 to 6 is implemented.