Disclosure of Invention
In view of the above, an object of the present invention is to provide a method for standardizing an access request port, a device for standardizing an access request port, an electronic device, and a computer-readable storage medium, which avoid port collision and ensure that a user can access the port normally.
In order to solve the above technical problem, the present application provides a method for standardizing an access request port, including:
acquiring an access request, and extracting a destination port corresponding to the access request;
judging whether the destination port is a preset port or not;
if the port is the preset port, acquiring a standard port corresponding to the target port, and generating a standard request by using the standard port;
sending the standard request to an agent module of a monitoring target port, and carrying out agent access by utilizing the agent module according to server configuration; the destination port comprises the standard port.
Optionally, the determining whether the destination port is a preset port includes:
identifying a transmission protocol corresponding to the access request;
acquiring port information corresponding to the transmission protocol, and judging whether the port information comprises the target port;
and if the destination port is included, determining that the destination port is the preset port.
Optionally, before acquiring the port information corresponding to the transmission protocol, the method further includes:
acquiring a plurality of port configuration data, and extracting a non-standard port and the transmission protocol corresponding to each port configuration data;
classifying the non-standard ports based on the transmission protocol to obtain initial port information;
and carrying out duplicate removal processing on the initial port information to obtain the port information.
Optionally, the method further comprises:
and acquiring updating data, and updating the port information by using the updating data.
Optionally, the obtaining of the standard port corresponding to the destination port includes:
and identifying a transmission protocol corresponding to the access request, and acquiring the standard port according to the transmission protocol.
Optionally, the performing, by using the proxy module, proxy access according to server configuration includes:
acquiring host data in the standard request by using the agent module;
determining target server configuration corresponding to the host data from the server configuration;
and carrying out proxy access by utilizing the target server configuration.
Optionally, the performing, by using the target server configuration, a proxy access includes:
analyzing the configuration of the target server to obtain a server address and a server port:
generating a server access request by using the server address and the server port;
and sending the server access request to a target server corresponding to the target server configuration.
The present application also provides a standardized apparatus for an access request port, comprising:
the acquisition module is used for acquiring an access request and extracting a destination port corresponding to the access request;
the judging module is used for judging whether the destination port is a preset port or not;
the port conversion module is used for acquiring a standard port corresponding to the target port if the preset port is the target port, and generating a standard request by using the standard port;
the proxy access module is used for sending the standard request to a proxy module of a monitoring target port and carrying out proxy access according to server configuration by utilizing the proxy module; the destination port comprises the standard port.
The present application further provides an electronic device comprising a memory and a processor, wherein:
the memory is used for storing a computer program;
the processor is used for executing the computer program to realize the standardized method of the access request port.
The present application also provides a computer readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the standardized method of access request port described above.
The standardized method of the access request port obtains the access request and extracts the destination port corresponding to the access request; judging whether the destination port is a preset port or not; if the port is the preset port, acquiring a standard port corresponding to the target port, and generating a standard request by using the standard port; sending the standard request to an agent module of a monitoring target port, and carrying out agent access by using the agent module according to the server configuration; the destination port comprises a standard port.
It can be seen that in this method, the agent module is used to perform the work of agent access, which only listens to the segment port, i.e. receives and responds to the requests of the standard port. After the access request is obtained, whether a corresponding destination port is a standard port or not is judged, and the destination port is a port for providing service for the server. If the destination port is not a standard port, the request is not monitored by the agent module, so that the corresponding standard port is obtained, a standard request is generated, and the standard request is sent to the agent module. The proxy module can monitor the target port, and the target port comprises a standard port, so that the proxy module can monitor the standard request, and can determine the server which the standard request wants to access according to the server configuration to complete the proxy access. The proxy module only needs to monitor the target port and does not need to monitor the ports of all the servers, and the standard port corresponding to the target port belonging to the preset port is used for generating the standard request, so that the proxy module can monitor the standard request and perform corresponding proxy access to complete the processing of the access request. The access request with the preset ports is converted into the standard request, so that the number of the ports monitored by the agent module can be reduced, the number of the target ports is far smaller than that of the ports for providing services to the outside by the server, a large number of ports can be reserved for initiating connection to the website server, port conflict is avoided, normal access of a user is guaranteed, and the problem of port conflict existing in the related technology is solved.
In addition, the application also provides a standardized device of the access request port, the electronic equipment and a computer readable storage medium, which also have the beneficial effects.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a flowchart illustrating a standardized method for accessing a request port according to an embodiment of the present disclosure. The method comprises the following steps:
s101: and acquiring the access request and extracting a destination port corresponding to the access request.
Some or all of the steps in this embodiment may be executed by a cloud WAF, which is a WAF (Web Application Firewall, website Application level intrusion prevention system) deployed in the cloud. The cloud WAF may change an original flow direction of the network traffic through a DNS (Domain Name System) scheduling technology, and pull the network traffic to itself so as to process the access request. The access request is transmitted based on an HTTP (HyperText Transfer Protocol) Protocol or an HTTPs (HyperText Transfer Protocol over Secure Socket Layer), and specific contents thereof are not limited. The embodiment does not limit the specific obtaining manner of the access request, and may refer to related technologies, which are not described herein. After obtaining the access request, the destination port that the access request wants to access may be extracted. The destination port is a port for providing services to the outside of the website server, and may be a standard port, for example, an 80 port corresponding to the HTTP protocol, or a non-standard port, for example, an 8080 port or 60000 port.
S102: and judging whether the destination port is a preset port or not.
Since the port through which the website server provides the service may be a standard port or a non-standard port, in order to process the service request corresponding to each website server in the related art, a plurality of interfaces are required to monitor the interfaces through which all the servers provide the service, so as to respond to the access request of any one website server after the access request is obtained. However, this occupies the ports of the cloud WAF itself, and is liable to cause port collision.
In order to solve the problem, in the application, only the target port is monitored, that is, the proxy module for monitoring the target port is used for proxy access, and an access request corresponding to a preset port is standardized. The target port comprises a standard port and can also comprise a part of non-standard ports in one embodiment, and the preset port and the target port can cover all the non-standard ports; or only the non-standard ports may be covered, in which case the non-standard ports that are not covered cannot be processed, and therefore, it is preferable that the preset ports and the destination ports include all the non-standard ports. It can be understood that, when an access request is obtained, in order to determine whether the access request can be directly processed, it is necessary to determine whether a destination port of the access request is a preset port, and in order to enable the proxy module to identify the access request having the preset port, the access request needs to be converted to generate a corresponding standard request.
Specifically, after the destination port is obtained, it is first determined whether the destination port is a preset port, it can be understood that the preset port is necessarily a non-standard port, and if the destination port is a standard port, the preset port can be directly monitored and processed by the proxy module. The preset port may be any one of non-standard ports, or may be any one of non-standard ports for providing services to the outside by a plurality of website servers corresponding to the proxy module. The present embodiment does not limit a specific determination manner, and the determination manner is different according to different actual meanings of the preset port, for example, when the preset port is a non-standard port, it may be directly determined whether the destination port is a standard port, and if not, the destination port is determined as the preset port.
In a specific embodiment, the step S102 may include:
step 11: a transport protocol corresponding to the access request is identified.
The transmission protocol specifically refers to an HTTP protocol or an HTTPs protocol, and since the two transmission protocols respectively correspond to different standard ports, the HTTP protocol corresponds to an 80 port, and the HTTPs protocol corresponds to a 443 port, the transmission protocol corresponding to the access request is identified before determining whether the destination port is a preset port. The present embodiment does not limit the specific identification manner, and any existing identification manner may be adopted, which is not described herein again.
Step 12: and acquiring port information corresponding to the transmission protocol, and judging whether the port information comprises a destination port.
The embodiment does not determine the specific acquisition mode of the port information, and for example, the port information may be locally generated and then stored, and directly read when being acquired; or may be input externally, such as by transmission from other electronic devices or manually by a user. By identifying the transmission protocol and selecting the corresponding port information, whether the destination port is a preset port can be accurately judged.
In order to flexibly adjust the processing mode of the access request, the preset port can be recorded by using the port information, and the non-standard port which is not recorded by the port information is determined as the target port. For example, in an implementation, in order to increase the overall processing speed of the access request, the port information may record a non-standard port corresponding to a part of the servers, so as to convert a part of the access request into a standard request, and process another part of the access request in the original manner, which may also reduce the number of ports that the proxy module needs to listen to. Or in another embodiment, in order to reduce the number of ports that the proxy module needs to monitor as much as possible, all non-standard ports except the standard port of the transport protocol may be recorded by using the port information, or all non-standard ports corresponding to the server may be recorded by using the port information.
After the port information is obtained, the port information is screened to judge whether a target port exists. If the destination port is not included, it indicates that the destination port may be a standard port or a non-standard port that does not need to be converted, and in this case, the destination port may be directly sent to the proxy module so that the proxy module directly processes the destination port.
Step 13: and if the destination port is included, determining the destination port as a preset port.
If the port information includes the destination port, the destination port is a preset port. The access request needs to be converted into a standard request.
In one embodiment, before determining whether the destination port is a preset port by using the port information, the port information may be locally generated. Specifically, before acquiring the port information corresponding to the transmission protocol, the method may further include:
step 21: and acquiring a plurality of port configuration data, and extracting a non-standard port and a transmission protocol corresponding to each port configuration data.
Step 22: and classifying the non-standard ports based on the transmission protocol to obtain initial port information.
Step 23: and carrying out duplicate removal processing on the initial port information to obtain the port information.
In this embodiment, the port configuration data corresponds to each website server, and records a transmission protocol used by the access request and a port providing a service. Therefore, after the port configuration data is obtained, the corresponding port and the transmission protocol can be extracted, after the standard port is filtered based on the transmission protocol, the non-standard ports corresponding to all the port configuration data can be obtained, and the non-standard ports are classified based on the transmission protocol to obtain the initial port information. Because different website servers may adopt the same non-standard port, the original port information is subjected to deduplication processing, and repeated parts are deleted to obtain the port information. The port information obtained by the generation mode records all nonstandard ports adopted by the website server, namely, the nonstandard ports adopted by the website server are all determined as preset ports, so that the number of the ports which need to be monitored by the proxy module can be reduced to the maximum extent, and the problem of port conflict is avoided to the maximum extent.
Further, the port information may be updated in real time, and therefore, the method may further include:
step 31: and acquiring the updating data, and updating the port information by using the updating data.
The embodiment does not limit the specific content of the update data, for example, in an implementation, the update data may be completely new port information, and at this time, the update data is used to replace the original port information, so that the update of the port information can be completed. In another embodiment, the update data may include a non-standard port having a mark, and the mark may include an addition mark and a deletion mark, and the addition or deletion of the non-standard port recorded in the port information may be performed by adding a mark to the non-standard port. It can be understood that, in the port information, the non-standard port with the added mark in the update data is not recorded originally, and the non-standard port with the deleted mark in the update data should be recorded in the port information. By updating the port information, the specific content of the preset port can be flexibly adjusted, and the processing mode of the access request can be flexibly adjusted.
S103: and acquiring a standard port corresponding to the destination port, and generating a standard request by using the standard port.
After the destination port is determined to be the preset port, it indicates that the agent module does not monitor the destination port, and the access request can be monitored and processed by the agent module only if the access request needs to be converted into a standard request. Therefore, the standard port corresponding to the destination port is obtained, and the standard port is used for generating the standard request. The standard request differs from the access request only in the destination port, and is otherwise identical. Specifically, a transmission protocol corresponding to the access request may be identified, and the standard port may be obtained according to the transmission protocol.
S104: and sending the standard request to an agent module of the monitoring target port, and carrying out agent access by using the agent module according to the server configuration.
After generating the standard request, it may be sent to the agent module listening to the target port. The agent module can monitor the standard request, and after the standard request is obtained, the agent module is used for carrying out agent access. It should be noted that, in the present application, the server configuration records server ports corresponding to all the web servers corresponding to the proxy module, and the server port provides a port for providing services to the web server, that is, a destination port in the access request. Because the destination port in the standard request is the standard port, and the target server corresponding to the access request does not provide service through the standard port, the purpose of converting the access request into the standard request is only to enable the proxy module to monitor the request, and the target server cannot be normally accessed through the standard port. Therefore, when actually performing proxy access, it is also necessary to determine a server port by using server configuration and perform proxy access by using the server port.
Specifically, in an embodiment, the step of performing proxy access according to the server configuration by using the proxy module may include:
step 41: and acquiring host data in the standard request by using the proxy module.
Step 42: and determining the target server configuration corresponding to the host data from the server configurations.
Step 43: proxy access is performed using the target server configuration.
The host data in the standard request is the host data in the access request, and can be used to determine which website server the access request wants to access, and the proxy access can be performed only after determining the website server the access request wants to access (i.e. the target server). Therefore, when the proxy access is carried out, the host data in the standard request is obtained, the host data is used for screening in the server configuration, the target server configuration corresponding to the target server is obtained, and the proxy access is carried out by using the target server configuration.
Further, step 43 may comprise:
step 44: and analyzing the configuration of the target server to obtain the address and the port of the server.
Step 45: a server access request is generated using the server address and the server port.
Step 46: and sending the server access request to a target server configuration corresponding to the target server.
The target server configuration records a server address and a server port, and the server address is specifically an IP address. And after the server address and the server port are obtained, generating a server access request by using the server address and the server port, sending the server access request to the target server to realize the access to the target server, and responding the server access request by the target server to realize the access of the user to the target server.
S105: and (5) presetting operation.
If the destination port is not the preset port, it means that it is not necessary to convert it into a standard port for the agent module to monitor, and at this time, it may be directly sent to the agent module, or no operation may be performed, i.e., no operation is performed.
By applying the standardized method for accessing the request port provided by the embodiment of the application, the agent module is used for executing the work of agent access, and only monitors the mark section port, namely, receives and responds the request of the standard port. After the access request is obtained, whether a corresponding destination port is a standard port or not is judged, and the destination port is a port for providing service for the server. If the destination port is not a standard port, the request is not monitored by the agent module, so that the corresponding standard port is obtained, a standard request is generated, and the standard request is sent to the agent module. The proxy module can monitor the target port, and the target port comprises a standard port, so that the proxy module can monitor the standard request, and can determine the server which the standard request wants to access according to the server configuration to complete the proxy access. The proxy module only needs to monitor the target port and does not need to monitor the ports of all the servers, and the standard port corresponding to the target port belonging to the preset port is used for generating the standard request, so that the proxy module can monitor the standard request and perform corresponding proxy access to complete the processing of the access request. The access request with the preset ports is converted into the standard request, so that the number of the ports monitored by the agent module can be reduced, the number of the target ports is far smaller than that of the ports for providing services to the outside by the server, a large number of ports can be reserved for initiating connection to the website server, port conflict is avoided, normal access of a user is guaranteed, and the problem of port conflict existing in the related technology is solved.
Based on the above embodiments, this embodiment describes an overall process of processing an access request. Referring to fig. 2, fig. 2 is a flowchart illustrating a standardized procedure of an access request port according to an embodiment of the present disclosure. The client is a client, specifically a generation and sending end of the access request, a destination IP of the access request is a service IP, the service IP is an IP used by the cloud WAF to obtain the access request, and a domain name of a website server corresponding to the cloud WAF is analyzed to obtain the service IP. In this embodiment, a firewall FW is further provided in front of the cloud WAF, and is configured to perform destination address translation (i.e., DNAT), direct traffic corresponding to the service IP to a monitoring IP of the cloud WAF, where the monitoring IP is an intranet IP of the cloud WAF, and receive HTTP and HTTPs traffic sent by the client by monitoring the IP, so as to obtain the access request. And after obtaining the access request, the cloud WAF executes the processing step of the access request, and performs source returning by using a source returning IP (Internet protocol), wherein the source returning is a process of accessing the website server by the cloud WAF, namely a process of performing proxy access. It should be noted that, because the proxy module in the cloud WAF only monitors a small number of target ports, the monitoring IP may provide a large number of ports for the cloud WAF to establish connection with the web server through the proxy module, and therefore, in this embodiment, the source-returning IP is the monitoring IP. When proxy access is actually performed, the IP that reaches the source station (i.e., web1, web2, etc. in the figure) is usually the public network IP obtained after source address conversion (i.e., SNAT) processing through a firewall. In another related technology, the back source IP is set to be any IP other than the monitoring IP, so that the number of usable ports in the back source is increased, and the effect of avoiding port collision is achieved. However, this related art requires a change to the back-source IP so that it cannot be the same as the listening IP, which makes development workload and maintenance costs large.
It can be understood that the number of ports monitored by the proxy module can be reduced by converting the destination port belonging to the preset port into the standard port, so that port conflict is avoided, and meanwhile, the back source IP does not need to be set, so that the back source IP can be the same as the monitored IP, extra development and maintenance are not needed, and the workload and the maintenance cost are reduced.
The following describes an access request port standardization apparatus provided in an embodiment of the present application, and the access request port standardization apparatus described below and the access request port standardization method described above may be referred to in correspondence with each other.
Referring to fig. 3, fig. 3 is a schematic structural diagram of a standardized apparatus for accessing a request port according to an embodiment of the present application, including:
an obtaining module 110, configured to obtain an access request and extract a destination port corresponding to the access request;
a judging module 120, configured to judge whether the destination port is a preset port;
a port conversion module 130, configured to, if the port is a preset port, obtain a standard port corresponding to the destination port, and generate a standard request by using the standard port;
the proxy access module 140 is used for sending the standard request to a proxy module of the monitoring target port and carrying out proxy access by using the proxy module according to the server configuration; the destination port comprises a standard port.
Optionally, the determining module 120 includes:
the first identification unit is used for identifying a transmission protocol corresponding to the access request;
the port information judging unit is used for acquiring port information corresponding to the transmission protocol and judging whether the port information comprises a target port;
and the preset port determining unit is used for determining the destination port as the preset port if the destination port is included.
Optionally, the method further comprises:
the port configuration data acquisition unit is used for acquiring a plurality of port configuration data and extracting a non-standard port and a transmission protocol corresponding to each port configuration data;
the classification unit is used for classifying the non-standard ports based on the transmission protocol to obtain initial port information;
and the duplicate removal processing unit is used for carrying out duplicate removal processing on the initial port information to obtain the port information.
Optionally, the method further comprises:
and the updating unit is used for acquiring the updating data and updating the port information by using the updating data.
Optionally, the port conversion module 130 includes:
and the second identification unit is used for identifying the transmission protocol corresponding to the access request and acquiring the standard port according to the transmission protocol.
Optionally, the agent access module 140 includes:
the data acquisition unit is used for acquiring host data in the standard request by using the agent module;
the configuration determining unit is used for determining target server configuration corresponding to host data from the server configuration;
and the access unit is used for carrying out proxy access by utilizing the configuration of the target server.
Optionally, the access unit comprises:
the analysis subunit is used for analyzing the configuration of the target server to obtain a server address and a server port:
a request generation subunit, configured to generate a server access request using the server address and the server port;
and the sending subunit is used for sending the server access request to a target server corresponding to the target server configuration.
In the following, the electronic device provided by the embodiment of the present application is introduced, and the electronic device described below and the standardized method for accessing the request port described above may be referred to correspondingly.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. Wherein the electronic device 100 may include a processor 101 and a memory 102, and may further include one or more of a multimedia component 103, an information input/information output (I/O) interface 104, and a communication component 105.
The processor 101 is configured to control the overall operation of the electronic device 100 to complete all or part of the steps in the standardized method for accessing the request port; the memory 102 is used to store various types of data to support operation at the electronic device 100, such data may include, for example, instructions for any application or method operating on the electronic device 100, as well as application-related data. The Memory 102 may be implemented by any type or combination of volatile and non-volatile Memory devices, such as one or more of Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic or optical disk.
The multimedia component 103 may include a screen and an audio component. Wherein the screen may be, for example, a touch screen and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 102 or transmitted through the communication component 105. The audio assembly also includes at least one speaker for outputting audio signals. The I/O interface 104 provides an interface between the processor 101 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 105 is used for wired or wireless communication between the electronic device 100 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination of one or more of them, so that the corresponding Communication component 105 may include: Wi-Fi part, Bluetooth part, NFC part.
The electronic Device 100 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components, and is used to perform the standardized method for the access request port according to the above embodiments.
The following describes a computer-readable storage medium provided by an embodiment of the present application, and the computer-readable storage medium described below and the standardized method of the access request port described above may be referred to correspondingly.
The present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the standardized method of accessing a request port described above.
The computer-readable storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative components and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it should also be noted that, herein, relationships such as first and second, etc., are intended only to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms include, or any other variation is intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
The principle and the implementation of the present application are explained herein by applying specific examples, and the above description of the embodiments is only used to help understand the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.