Disclosure of Invention
The embodiment of the application provides an automatic modification method, an automatic modification system and electronic equipment for a website access port, which are used for at least solving the problem of poor modification efficiency during port modification in the related technology.
In a first aspect, an embodiment of the present application provides an automated modification method for a website access port, including:
Responding to a port acquisition request sent by a front end, acquiring a port number from a configuration file of Nginx 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, wherein the port configuration information is acquired by the front end based on the port configuration interface, updating the configuration file based on the port configuration information, and modifying a port number based on the updated configuration file;
Restarting the Nginx according to a preset configuration instruction, so that the modified port number is effective.
In an embodiment, the updating the configuration file includes:
and modifying all port numbers in the configuration file into port numbers in the port configuration information according to a preset modification function.
In an embodiment, the updating the configuration file includes:
And 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.
In one embodiment, if restarting nmginx fails, the method includes:
Determining error configuration information with problems according to the restarting operation result, deleting the error configuration information in the configuration file, or
And according to the preset instruction, terminating the Nginx process and restarting the Nginx process.
In an embodiment, the method further comprises:
And after the restarting is successful, the modified result and the modified port number are sent to the front end so that the front end can display according to the modified result and the modified port number.
In an embodiment, the method further comprises:
And receiving login information sent by the front end in response to a user login instruction, and logging in a website according to the login information so that the user uses each interface in the website, wherein the login information comprises an IP address and a modified port number.
In a second aspect, an embodiment of the present application provides an automated modification system for a website access port, the system including:
The port configuration display module is used for displaying a configuration interface for a user so that the user can configure the port;
The port modification module is used for realizing the automatic modification method of the website access port according to any one of claims 1-6.
In an embodiment, the system further comprises:
the modification result display module is used for displaying a modification result and a modified port number so as to remind a user of successful modification;
and the login module is used for logging in the website according to the IP address and the modified port number so that the user can normally use each interface in the website.
In a third aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the method for automatically modifying a website access port according to the first aspect when the processor executes the computer program.
In a fourth aspect, an embodiment of the present application provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a method for automatically modifying a website access port as described in the first aspect above.
The automatic modification method, the system and the electronic equipment for the website access port provided by the embodiment of the application have at least the following technical effects.
The application simply and conveniently uses the visual interface for modifying the port, the user only needs to operate the interface at the port configuration, after receiving the port configuration information of the user, the application automatically modifies the configuration file of the Nginx according to the port configuration information and automatically restarts the Nginx after modification. The method solves the problems that the configuration file is required to be manually searched when the port is manually modified, and the port numbers of all target positions in the configuration file are required to be manually modified, thereby wasting time and labor. In this way, the access port is automatically modified, the problems of time and labor waste in the prior art are effectively solved, the whole operation is convenient, and the user experience is improved. And under the condition that the port is occupied, the access port is automatically modified, so that the flexibility of website access is improved.
The details of one or more embodiments of the application are set forth in the accompanying drawings and the description below to provide a more thorough understanding of the other features, objects, and advantages of the application.
Detailed Description
The present application will be described and illustrated with reference to the accompanying drawings and examples in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application. All other embodiments, which can be made by a person of ordinary skill in the art based on the embodiments provided by the present application without making any inventive effort, are intended to fall within the scope of the present application.
It is apparent that the drawings in the following description are only some examples or embodiments of the present application, and it is possible for those of ordinary skill in the art to apply the present application to other similar situations according to these drawings without inventive effort. Moreover, it should be appreciated that while such a development effort might be complex and lengthy, it would nevertheless be a routine undertaking of design, fabrication, or manufacture for those of ordinary skill having the benefit of this disclosure, and thus should not be construed as having the benefit of this disclosure.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is to be expressly and implicitly understood by those of ordinary skill in the art that the described embodiments of the application can be combined with other embodiments without conflict.
Unless defined otherwise, technical or scientific terms used herein should be given the ordinary meaning as understood by one of ordinary skill in the art to which this application belongs. The terms "a," "an," "the," and similar referents in the context of the application are not to be construed as limiting the quantity, but rather as singular or plural. The terms "comprises," "comprising," "includes," "including," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or modules (elements) is not limited to only those steps or elements but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. The terms "connected," "coupled," and the like in connection with the present application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The term "plurality" as used herein means two or more. "and/or" describes the association relationship of the association object, and indicates that three relationships may exist, for example, "a and/or B" may indicate that a exists alone, a and B exist simultaneously, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship. The terms "first," "second," "third," and the like, as used herein, are merely distinguishing between similar objects and not representing a particular ordering of objects.
In a first aspect, an embodiment of the present application provides an automatic modification method for a website access port, where the method provided by the present application is implemented mainly based on JAVA and VUE2 technology stacks. FIG. 1 is a flowchart of an automated modification method of a website access port according to an embodiment of the present application, as shown in FIG. 1, the method includes:
Step S101, in response to receiving a port acquisition request sent by the front end, acquiring a port number from a configuration file of Nginx and sending the port number to the front end, so that the front end displays a port configuration interface based on the port number.
Alternatively, nmginx is a high-performance Web server and reverse proxy server that is widely used to handle HTTP requests, with many forwarding ports configured on nmginx. After receiving the port acquisition request sent by the front end, the back end acquires the configuration port number from the nginx.conf configuration file of the Nginx through a port acquisition method and returns the configuration port number to the front end. The front end acquires port information from the back end through Axios call interfaces. After the port information is acquired, the front end displays a port configuration interface through the Vue so that a user can modify the port number. The port configuration interface at least comprises a text box for filling in a new port number and a determination button.
In this way, the port is modified simply and conveniently by using the graphical interface, and the user can realize automatic modification of the port by a subsequent method only by setting the port number on the port configuration interface. The whole simple operation is favorable to promoting user experience and feels.
Step S102, receiving port configuration information sent by a front end, wherein the port configuration information is acquired by the front end based on a port configuration interface, updating a configuration file based on the port configuration information, and modifying a port number based on the updated configuration file.
Optionally, the front end returns port configuration information to the back end through Axios call interfaces, where the port configuration information is generated according to the user's settings at the port configuration interface. After receiving the port configuration information, the back end writes the port number in the port configuration information into the configuration file of Nginx by using the IO stream method of the bottom layer, and then modifies the port number at the target position according to the port number written in the configuration file. The target position is the same position as the port number acquired in step S101. When the port is manually modified, the configuration file is manually searched, and the port numbers of all target positions in the configuration file are manually modified, so that time and labor are wasted. In this way, the access port is automatically modified, so that the problems of time and labor waste in the prior art are effectively solved, and the user experience is improved.
In one example, updating the configuration file in step S102 includes modifying all port numbers in the configuration file to port numbers in the port configuration information according to a preset modification function. Alternatively, all the port numbers in the configuration file that are the same as the port numbers acquired in step S101 are modified to the port numbers in the port configuration information.
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 content in the port modification file. Optionally, the part of the port configuration file configured for the same port number as the port number acquired in step S101 is deleted, and modified into the part of the port modification file configured for 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 configured for the new port number may be directly added to the configuration file.
By the two methods for updating the configuration file, the automatic modification of the port is realized. The whole simple operation is favorable to promoting user experience and feels.
Step S103, restarting Nginx according to a preset configuration instruction, and enabling the modified port number to be effective.
Optionally, after modifying the port, the nginnx needs to be restarted to validate the modified port number. The method for restarting the Nginx is a method for calling a CMD command line according to a preset configuration command and executing a restarting command of the Nginx to restart the Nginx and further realize complete automatic port modification. When the port is manually modified, the Nginx needs to be manually restarted after the configuration file is manually modified. According to the automatic modification method for the website access port, the program is used for automatically calling the command line to restart Nginx, the port is automatically restarted after the port is modified, a user only needs to click and determine after the port is modified by the port configuration interface, no additional operation is needed, automatic modification of the port is achieved, the whole operation is convenient, and the user experience is improved.
In one example, if the restarting of the nmginx fails, the method further includes determining error configuration information with a problem according to the operation result after the restarting, and deleting the error configuration information in the configuration file. Or according to a preset instruction, terminating the Nginx process and restarting the Nginx process.
Alternatively, a problem of no start-up may occur when nmginx is restarted. At this time, there may be a problem with the allocation in the modified configuration file, or a problem with the process of Nginx, and the failure to restart Nginx is basically caused by both aspects. Therefore, the problem of the failure of the Nginx restart is solved by deleting the wrong configuration in the configuration file or stopping the restarting of the Nginx process.
In one example, the method further comprises the step of sending the modification result and the modified port number to the front end after the restart is successful, so that the front end can 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 of the successful modification.
In one example, the method further includes receiving login information sent by the front end in response to the user login instruction, logging in to the website according to the login information, such that the user uses various interfaces in the website, the login information including the IP address and the modified port number. Optionally, after the user has modified the port number, the original port number may no longer be able to display the web page. The IP and the new port number are required to be input by oneself, the user name and the password are input to log in the website after the webpage is opened, and various functions of the website are normally used through various interfaces of the website.
In this way, under the condition that the computer port is occupied, the access port is automatically modified, and the access of the website is performed by using the port required by the user, so that the flexibility of the access of the website is improved.
In summary, the graphical interface is simply and conveniently used for modifying the port, and the user can realize the automatic modification of the port only by clicking and determining after the port is configured with the interface for modifying the port without any additional operation. After receiving the port configuration information of the user, the application automatically modifies the configuration file of the Nginx according to the port configuration information and automatically restarts the Nginx after modification. The method solves the problems that the configuration file is required to be manually searched when the port is manually modified, and the port numbers of all target positions in the configuration file are required to be manually modified, thereby wasting time and labor. In this way, the access port is automatically modified, the problems of time and labor waste in the prior art are effectively solved, the whole operation is convenient, and the user experience is improved. And under the condition that the port is occupied, the access port is automatically modified, so that the flexibility of website access is improved.
In a second aspect, an embodiment of the present application provides an automated modification system for a website access port, and fig. 2 is a structural block diagram of an automated modification system for a website access port provided according to an embodiment of the present application, as shown in fig. 2, where the system includes:
The port configuration display module 100 is configured to display a configuration interface to a user for the user to configure the port. Optionally, the port configuration interface includes at least a text box to fill in the new port number and a ok button.
Port modification module 200. An automated modification method for implementing the website access port of the first aspect.
In one example, the system further comprises:
and the modification result display module 300 is used for displaying the modification result and the modified port number so as to remind the user of successful modification.
The login module 400 is used for logging in the website according to the IP address and the modified port number, so that the user can normally use each interface in the website. Optionally, the user enters the opened webpage according to the IP address and the modified port number, then inputs a user name password to log in the website, and normally uses various functions of the website through various interfaces of the website.
In summary, the graphical interface is simply and conveniently used for modifying the port, and the user can realize the automatic modification of the port only by clicking and determining after the port is configured with the interface for modifying the port without any additional operation. After receiving the port configuration information of the user, the application automatically modifies the configuration file of the Nginx according to the port configuration information and automatically restarts the Nginx after modification. The method solves the problems that the configuration file is required to be manually searched when the port is manually modified, and the port numbers of all target positions in the configuration file are required to be manually modified, thereby wasting time and labor. In this way, the access port is automatically modified, the problems of time and labor waste in the prior art are effectively solved, the whole operation is convenient, and the user experience is improved. And under the condition that the port is occupied, the access port is automatically modified, so that the flexibility of website access is improved.
In a third aspect, an embodiment of the present application provides an electronic device, and fig. 3 is a schematic structural diagram of the electronic device provided in the embodiment of the present application. The electronic device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor executes the program to implement the method for automatically modifying a website access port provided in the first aspect, and the electronic device 60 shown in fig. 3 is merely an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present application.
The electronic device 60 may be in the form of a general purpose computing device, which may be a server device, for example. The components of the electronic device 60 may include, but are not limited to, the at least one processor 61, the at least one memory 62, and a bus 63 that connects the various system components, including the memory 62 and the processor 61.
The bus 63 includes a data bus, an address bus, and a control bus.
Memory 62 may include volatile memory such as Random Access Memory (RAM) 621 and/or cache memory 622, and may further include Read Only Memory (ROM) 623.
Memory 62 may also include a program/utility 625 with 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 or some combination of which may include an implementation of a network environment.
The processor 61 executes various functional applications and data processing, such as the automated modification method of the website access port provided in the first aspect of the present application, by running a computer program stored in the memory 62.
The electronic device 60 may also communicate with one or more external devices 64 (e.g., keyboard, pointing device, etc.). Such communication may occur through an input/output (I/O) interface 65. Also, the model-generating device 60 may also communicate with one or more networks, such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the internet, through a network adapter 66. As shown, the network adapter 66 communicates with other modules of the model-generating device 60 via the bus 63. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with the model-generating device 60, including, but not limited to, microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, among others.
It should be noted that although several units/modules or sub-units/modules of an electronic device are mentioned in the above detailed description, such a division is merely exemplary and not mandatory. Indeed, the features and functionality of two or more units/modules described above may be embodied in one unit/module in accordance with embodiments of the present invention. Conversely, the features and functions of one unit/module described above may be further divided into ones that are embodied by a plurality of units/modules.
In a fourth aspect, an embodiment of the present application provides a computer readable storage medium having a program stored thereon, where the program, when executed by a processor, implements the method for automatically modifying a website access port provided in the first aspect.
More specifically, a readable storage medium may include, but is not limited to, a portable disk, hard disk, random access memory, read only memory, erasable programmable read only memory, optical storage device, magnetic storage device, or any suitable combination of the foregoing.
In a possible implementation manner, the present invention may also be implemented in the form of a program product comprising program code for causing a terminal device to carry out the steps of implementing the automated modification method of the website access port provided in the first aspect, when said program product is run on the terminal device.
Wherein the program code for carrying out the invention may be written in any combination of one or more programming languages, which program code may execute entirely on the user device, partly on the user device, as a stand-alone software package, partly on the user device and partly on the remote device or entirely on the remote device.
The technical features of the above-described embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above-described embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.