Gateway proxy method and device, electronic device, and storage medium
Through automatic comparison and distribution of gateway lists by proxy servers, automatic certificate deployment and proxy management of gateway servers are realized, which solves the problems of certificate deployment complexity and high maintenance costs. It supports batch https connections and new gateway automatic proxy, simplifying development. or operate.
Patent Information
- Application Number
- CN202210090215.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-25
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2042-01-25
AI Technical Summary
In the existing technology, the certificate deployment of game gateway servers is complex and the maintenance cost is high. Especially when batch deployment or new gateway servers are required, manual intervention and configuration maintenance are cumbersome, and all gateway servers cannot be quickly supported.
The proxy server pulls the latest gateway list from the version management system, compares it with the historical list, automatically allocates unused proxy ports, and records the mapping relationship between gateways and proxy ports to implement message forwarding, so that only one proxy server is required to configure the certificate. , reducing certificate deployment complexity and maintenance costs.
It implements automated certificate deployment and gateway proxy management, reducing maintenance costs. It supports batch https connections and new gateway automatic proxies, simplifying developer operations and saving certificate configuration and maintenance work.
Smart Images

Figure CN114466065B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a gateway proxy method and device, an electronic device, and a computer-readable storage medium. Background Art
[0002] http is the Hypertext Transfer Protocol, a plain text transmission method. https is an upgraded version of http, used to ensure data transmission security. Certificates are used to ensure the security of https connections and are essential for https connections.
[0003] The game's gateway server usually uses https to connect, but for some gateway servers that use http to connect (for example, game developers use http to connect to internal gateway servers in order to deploy internal test environments), the game login must use https to connect to the gateway server due to the link restrictions of the login SDK. Therefore, in order to connect the game to these http gateway servers through https, batch certificate deployment is required. Installing certificates on each gateway server will make the internal gateway server deployment steps cumbersome, and it will not be possible to support all gateway servers in a short period of time. It will also be much more troublesome to deploy new gateway servers in the future. Summary of the invention
[0004] The embodiment of the present application provides a gateway proxy method to solve the problem of installing certificates on each gateway server, complex deployment, and high maintenance costs.
[0005] The embodiment of the present application provides a gateway proxy method, which is applied to a proxy server and includes:
[0006] Pull the latest gateway list from the version management system through the proxy server, and compare the latest gateway list with the historical gateway list;
[0007] If the latest gateway list is different from the historical gateway list, assigning an unused proxy port to a target gateway to which no proxy is assigned according to the latest gateway list, and recording a mapping relationship between the target gateway and the proxy port;
[0008] The message sent by the client to the designated proxy port is received through the proxy server, and the message is forwarded to the designated gateway corresponding to the designated proxy port according to the mapping relationship between each gateway and the proxy port.
[0009] In one embodiment, the step of pulling the latest gateway list from the version management system through the proxy server includes:
[0010] The monitoring program installed on the proxy server periodically pulls the latest gateway list from the version management system.
[0011] In one embodiment, comparing the latest gateway list with the historical gateway list includes:
[0012] Calculate the first information digest value of the latest gateway list and the second information digest value of the historical gateway list by the proxy server;
[0013] Compare the first information digest value and the second information digest value to see if they are consistent, and if they are inconsistent, determine that the latest gateway list is different from the historical gateway list.
[0014] In one embodiment, recording the mapping relationship between the target gateway and the proxy port includes:
[0015] The proxy server generates a gateway update list according to the proxy port correspondingly allocated to each gateway; the gateway update list includes the domain name of the proxy server, multiple proxy port identifiers, and the gateway address and gateway port identifier corresponding to each proxy port identifier.
[0016] In one embodiment, after generating the gateway update list, the method further includes:
[0017] Generate a proxy configuration file for the nginx service through the proxy server according to the gateway update list;
[0018] A new process is established to establish the https service according to the proxy configuration file, and the old process corresponding to the historical gateway list is closed.
[0019] In one embodiment, after generating the gateway update list, the method further includes:
[0020] The proxy server uses the gateway update list to replace the historical gateway list.
[0021] In one embodiment, after generating the gateway update list, the method further includes:
[0022] The gateway update list is sent to the client and the version management system through the proxy server.
[0023] In one embodiment, the receiving, by the proxy server, a message sent by the client to the designated proxy port, and forwarding the message to a designated gateway corresponding to the designated proxy port according to a mapping relationship between each gateway and the proxy port, includes:
[0024] Receiving, through the proxy server, a message sent by the client to a designated proxy port according to the gateway update list;
[0025] The proxy server forwards the message to the designated port of the designated gateway corresponding to the gateway address and the gateway port identifier according to the gateway address and the gateway port identifier corresponding to the designated proxy port indicated in the proxy configuration file.
[0026] In one embodiment, the receiving, by the proxy server, a message sent by the client to the designated proxy port according to the gateway update list includes:
[0027] The message sent by the client to the designated proxy port based on the https protocol according to the gateway update list is received through the nginx service of the proxy server.
[0028] In one embodiment, forwarding the message to a designated port of a designated gateway corresponding to the gateway address and the gateway port identifier indicated in the proxy configuration file includes:
[0029] The message is forwarded to the designated port of the designated gateway corresponding to the gateway address and the gateway port identifier based on the http protocol through the nginx service of the proxy server according to the gateway address and the gateway port identifier corresponding to the proxy port indicated in the proxy configuration file.
[0030] In a second aspect, an embodiment of the present application provides a proxy device of a gateway, the device is applied to a proxy server, and the device includes:
[0031] A list pulling module is used to pull the latest gateway list from the version management system and compare the latest gateway list with the historical gateway list;
[0032] A port allocation module, configured to allocate an unused proxy port to a target gateway to which no proxy is allocated, and record a mapping relationship between the target gateway and the proxy port according to the latest gateway list if the latest gateway list is different from the historical gateway list;
[0033] The message forwarding module is used to receive a message sent by a client to a designated proxy port, and forward the message to a designated gateway corresponding to the designated proxy port according to a mapping relationship between each gateway and the proxy port.
[0034] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising:
[0035] processor;
[0036] a memory for storing processor-executable instructions;
[0037] Wherein, the processor is configured to execute the above-mentioned gateway proxy method.
[0038] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program can be executed by a processor to complete the above-mentioned gateway proxy method.
[0039] The technical solution provided by the above-mentioned embodiment of the present application compares the latest gateway list with the historical gateway list. If they are different, an unused proxy port is automatically assigned to the target gateway to which the proxy is not assigned, and the mapping relationship between the target gateway and the proxy port is recorded. Therefore, when receiving a message sent by a client to a designated proxy port, the message can be forwarded to the designated gateway corresponding to the designated proxy port according to the mapping relationship between each gateway and the proxy port. Therefore, only one proxy server needs to be configured with a certificate, which saves costs. A newly added gateway can automatically assign a proxy without manual intervention, which is flexible and convenient. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solution of the embodiments of the present application, the drawings required for use in the embodiments of the present application are briefly introduced below.
[0041] Figure 1 A schematic diagram of an application scenario of a gateway proxy method provided in an embodiment of the present application;
[0042] Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0043] Figure 3 It is a flowchart of the proxy method of the gateway provided in the embodiment of the present application;
[0044] Figure 4 This is a latest gateway list provided by the embodiment of the present application;
[0045] Figure 5 It is a gateway update list after the proxy port is allocated provided in the embodiment of the present application;
[0046] Figure 6 It is a schematic diagram of the steps of dynamic updating of the proxy provided in the embodiment of the present application;
[0047] Figure 7 It is a schematic diagram of the architecture of the proxy method of the gateway provided in the embodiment of the present application;
[0048] Figure 8 yes Figure 3 Detailed flowchart of step S330 in the corresponding embodiment;
[0049] Fig. 9 It is a block diagram of a proxy device of a gateway shown in an embodiment of the present application. DETAILED DESCRIPTION
[0050] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0051] Similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0052] In the prior art, a domain name is applied for and a certificate is installed for each gateway server, which makes deployment complicated. The certificate itself also needs to be purchased and updated when it expires, which has high maintenance costs. The embodiment of the present application uses a proxy method to solve this problem. The proxy server has a domain name corresponding to it and has a certificate installed. The client directly connects to the proxy server, and the proxy server forwards to other gateway servers. The prior art generally uses manual methods to modify and maintain proxy configurations, but manual maintenance of proxy configurations is complicated and cumbersome, which is not suitable for large-scale additions or modifications to gateway servers, and requires each developer to be familiar with the proxy configuration and update process, which has high maintenance costs. The method provided in the following embodiment of the present application can realize the automatic generation and update of the proxy, without the need for manual maintenance of the proxy configuration, thereby reducing maintenance costs. The following is a detailed description of the solution provided in the embodiment of the present application.
[0053] Figure 1 A schematic diagram of an application scenario of a proxy method of a gateway provided in an embodiment of the present application. The application scenario includes: a client 110, a proxy server 120, a gateway server 130, and a version management system 140. The client 110 is directly connected to the proxy server 120, the proxy server 120 is respectively connected to multiple gateway servers 130, and the gateway server 130 and the proxy server 120 are connected to the version management system 140. The version management system 140 can be an independent server for version management. In one embodiment, the version management system 140 can be SVN (an open source version control system).
[0054] The proxy server 120 is deployed with an https certificate. The client 110 can send a message to the designated proxy port of the proxy server 120 based on https. The proxy server 120 can forward the message to the gateway server 130 based on the http protocol according to the gateway server 130 configured corresponding to the designated proxy port. Therefore, the gateway server 130 does not need to install a certificate, and only one proxy server 120 needs to be configured with a certificate, which saves costs.
[0055] In order to overcome the defects of manually maintaining the proxy configuration, the proxy server 120 can execute the method provided in the embodiment of the present application, regularly pull the latest gateway list from the version management system 140, and compare the latest gateway list with the historical gateway list; if the latest gateway list is different from the historical gateway list, according to the latest gateway list, assign an unused proxy port to the target gateway to which the proxy is not assigned, and record the mapping relationship between the target gateway and the proxy port; receive a message sent by the client 110 to the designated proxy port, and forward the message to the designated gateway corresponding to the designated proxy port according to the mapping relationship between each gateway and the proxy port.
[0056] Therefore, when the developer modifies the gateway list, the proxy port allocation can be automatically triggered by comparing the latest gateway list with the historical gateway list, without manual intervention. By automatically counting the used ports and allocating an unused proxy port to the newly added gateway, it can not only support batch https for all http gateways, but also be suitable for automatic proxy of newly added gateways in the future. It is flexible and convenient. Other developers do not need to pay attention to the details of https and deploy certificates. They only need to modify the gateway list as before, and https support is completed without perception.
[0057] Figure 2 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device can be used as the above-mentioned proxy server 120, and the electronic device 200 can be used to execute the proxy method of the gateway provided in an embodiment of the present application. Figure 2 As shown, the electronic device 200 includes: one or more processors 202, and one or more memories 204 storing processor executable instructions. The processor 202 is configured to execute the proxy method of the gateway provided in the following embodiment of the present application.
[0058] The processor 202 may be a device including a central processing unit (CPU), a graphics processing unit (GPU), or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may process data of other components in the electronic device 200, and may also control other components in the electronic device 200 to perform desired functions.
[0059] The memory 204 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 202 may run the program instructions to implement the proxy method of the gateway described below. Various applications and various data, such as various data used and / or generated by the application, may also be stored in the computer-readable storage medium.
[0060] In one embodiment, Figure 2 The electronic device 200 shown may also include an input device 206, an output device 208, and a data acquisition device 210, and these components are interconnected via a bus system 212 and / or other forms of connection mechanisms (not shown). It should be noted that Figure 2 The components and structures of the electronic device 200 shown are merely exemplary and non-limiting. The electronic device 200 may also have other components and structures as required.
[0061] The input device 206 may be a device used by a user to input instructions, and may include one or more of a keyboard, a mouse, a microphone, a touch screen, etc. The output device 208 may output various information (e.g., images or sounds) to the outside (e.g., a user), and may include one or more of a display, a speaker, etc. The data acquisition device 210 may acquire an image of an object, and store the acquired image in the memory 204 for use by other components. Exemplarily, the data acquisition device 210 may be a camera.
[0062] In one embodiment, the various components in the example electronic device 100 for implementing the proxy method of the gateway of the embodiment of the present application can be integrated or dispersed, such as integrating the processor 202, memory 204, input device 206 and output device 208 into one, while separating the data acquisition device 210.
[0063] In one embodiment, the example electronic device 200 for implementing the proxy method of the gateway of the embodiment of the present application may be implemented as an intelligent device such as a computer, a server, etc.
[0064] Figure 3 Schematic diagram of the process flow of the gateway proxy method provided in the embodiment of the present application. Figure 3 As shown, the method includes the following steps S310-S330.
[0065] Step S310: Pull the latest gateway list from the version management system through the proxy server, and compare the latest gateway list with the historical gateway list.
[0066] The gateway is the gateway server mentioned above. The proxy server is deployed with a monitoring program, which can periodically pull the latest gateway list from SVN (version management system), referred to as the latest gateway list. The gateway list defines the IP address and port number of each gateway. Each developer can pull the gateway list from SVN through the gateway server to add, modify, and delete operations, and then upload it to SVN. The client also connects to the gateway based on the gateway list.
[0067] Figure 4 This is a latest gateway list provided by the embodiment of this application. Figure 4 As shown in the figure, the first line represents the gateway ID (1), the second line is the proxy server IP address (wss: / / nginx.g102-in,nie.ne.netease.com), the third line is the proxy port (30316), the fourth line is the gateway IP address (10.215.40.8), and the fifth line is the gateway port (9080). This means that messages sent to the proxy port 30316 will be forwarded to the gateway port 9080 whose gateway IP address is 10.215.40.8. Figure 4 As shown, Gateway 2 and Gateway 3 are newly added gateways and no proxy ports have been assigned yet.
[0068] The proxy server can compare the latest gateway list with the historical gateway list to determine whether the gateway list has been updated, so as to automatically trigger the allocation of proxy ports when an update occurs. The historical gateway list can be the gateway list after the most recent execution of proxy port allocation.
[0069] In one embodiment, the comparison of the gateway list can be performed by calculating a first information digest value of the latest gateway list and a second information digest value of the historical gateway list; comparing whether the first information digest value is consistent with the second information digest value, and if they are inconsistent, determining that the latest gateway list is different from the historical gateway list.
[0070] Specifically, the MD5 algorithm may be used to calculate the first information digest value of the latest gateway list and the second information digest value of the historical gateway list. The first information digest value refers to the information digest value of the latest gateway list, and the second information digest value refers to the information digest value of the historical gateway list. For distinction, they are divided into the first information digest value and the second information digest value. If the first information digest value is the same as the second information digest value, it means that the latest gateway list is the same as the historical gateway list. If the first information digest value is different from the second information digest value, it means that the latest gateway list is different from the historical gateway list.
[0071] Step S320: If the latest gateway list is different from the historical gateway list, an unused proxy port is allocated to a target gateway to which no proxy is allocated according to the latest gateway list, and a mapping relationship between the target gateway and the proxy port is recorded.
[0072] For the purpose of distinction, the gateway that is not assigned a proxy port is called the target gateway. Figure 4 As shown, gateway 2 and gateway 3 are both target gateways that are not assigned a proxy port. The proxy server can count all assigned proxy ports and randomly assign an unassigned port number between 10000-50000 to the target gateway that is not assigned a proxy as the proxy port of the target gateway.
[0073] Recording the mapping relationship between the target gateway and the proxy port refers to recording which proxy port the target gateway corresponds to. Therefore, each gateway is assigned a corresponding proxy port. The proxy port refers to the port of the proxy server. When the client sends a message to the proxy port of the proxy server, the proxy server can forward the message to the gateway corresponding to the proxy port.
[0074] In one embodiment, the proxy server may generate a gateway update list according to the proxy port correspondingly allocated to each gateway. The gateway update list may be obtained by updating the latest gateway list. Figure 5 This is the updated gateway list after assigning proxy ports. Figure 4 and Figure 5 , the previously unassigned proxy gateway 2 is assigned proxy port 23797, and the previously unassigned proxy gateway 3 is assigned proxy port 23915, thereby adding the proxy port of the target gateway that was originally unassigned proxy to the updated gateway list. Figure 5 As shown, the gateway update list includes the domain name of the proxy server, multiple proxy port identifiers, and the gateway address and gateway port identifier corresponding to each proxy port identifier.
[0075] like Figure 5As shown, the domain name of the proxy server may be wss: / / nginx.g102-in,nie.ne.netease.com. The proxy port identifier may be the port number of the proxy server, such as 23797. The gateway address corresponding to the proxy port identifier 23797 may be, for example, 192.168.41.21, and the gateway port identifier may be, for example, 9090.
[0076] It should be noted that the latest gateway list, historical gateway list and gateway update list are all relative. In an update event, the gateway update list is updated from the latest gateway list, and the gateway update list is used as the historical gateway list for the next update event. Therefore, after generating the gateway update list, the gateway update list can be used to replace the historical gateway list, and then compared with the latest gateway list to trigger the next proxy allocation.
[0077] Step S330: receiving a message sent by the client to the designated proxy port through the proxy server, and forwarding the message to the designated gateway corresponding to the designated proxy port according to the mapping relationship between each gateway and the proxy port.
[0078] The designated proxy port refers to any assigned proxy port. The designated gateway refers to the gateway corresponding to the designated port. For the purpose of distinction, it is called the designated gateway.
[0079] After assigning proxy ports to unassigned proxy gateways, the proxy server knows the assigned proxy ports corresponding to each gateway. Therefore, when the proxy server receives a message sent by the client to the specified port, it can forward the message to the gateway corresponding to the specified port.
[0080] by Figure 5 Taking the gateway update list shown as an example, assume that the proxy server receives a message sent by the client to the proxy port 23797. Since the gateway address corresponding to the proxy port identifier 23797 is 192.168.41.21 and the gateway port identifier is 9090, the proxy server can forward the message to the port 9090 of the gateway with the IP address 192.168.41.21.
[0081] The technical solution provided by the above-mentioned embodiment of the present application compares the latest gateway list with the historical gateway list. If they are different, an unused proxy port is automatically assigned to the target gateway to which the proxy is not assigned, and the mapping relationship between the target gateway and the proxy port is recorded. Therefore, when receiving a message sent by a client to a designated proxy port, the message can be forwarded to the designated gateway corresponding to the designated proxy port according to the mapping relationship between each gateway and the proxy port. Therefore, only one proxy server needs to be configured with a certificate, which saves costs. A newly added gateway can automatically assign a proxy without manual intervention, which is flexible and convenient.
[0082] In one embodiment, after the above step S320, that is, after the gateway update list is generated and the mapping relationship between the target gateway and the proxy port is recorded, Figure 6 As shown, the method provided in the embodiment of the present application also includes: step S601-step S602.
[0083] Step S601: Generate a proxy configuration file for the nginx service through a proxy server according to the gateway update list.
[0084] The proxy server has a corresponding domain name, IP address, an https certificate, and an nginx service (an asynchronous framework web server that can also be used as a reverse proxy, load balancer, and HTTP cache).
[0085] like Figure 7 As shown, the proxy server 120 uses the nginx service for proxy, and the client 110 connects to the nginx service of the proxy server 120 through the https protocol. The proxy server 120 is deployed with an https certificate and a proxy allocation program. The proxy allocation program monitors the modification of the gateway list (gatelist), allocates unused proxy ports to the gateways that are not assigned proxies, generates a gateway update list, and generates a proxy configuration file (i.e., nginx proxy configuration) to the nginx service. The proxy allocation program sends an update proxy notification to the nginx service, and then the nginx service can dynamically update the proxy. The nginx service can forward the message sent by the client 110 based on the https protocol to the gateway server 130 based on the http protocol. The addition and modification of the gateway server 130 are still configured according to http.
[0086] The proxy configuration file may include the proxy port to be listened, the domain name, the path of the log and error log, the path of the certificate, the IP address and port used during forwarding, and the HTTP version used.
[0087] Step S602: establish a new process to establish https service according to the proxy configuration file, and close the old process corresponding to the historical gateway list.
[0088] The proxy server executes the reload function of the nginx service to dynamically update the proxy configuration. The dynamic update process of the nginx service is to establish a new process to establish the https service according to the proxy configuration file, that is, to receive the https message from the client through a new process, forward the message to the gateway through http, and close the old process. Among them, the old process refers to the process corresponding to the historical gateway list. Here, the new process and the old process are relative. At the next update event, the current new process will become the old process and be closed.
[0089] In one embodiment, in order for both the client and the version management system to have the results of the most recent proxy allocation, after generating the gateway update list, the method provided in the embodiment of the present application may further include sending the gateway update list to the client and the version management system.
[0090] Therefore, the client can access the designated proxy port of the proxy server according to the gateway update list, and thus connect to the designated gateway corresponding to the designated proxy port. The version management system always has the latest gateway update list, which makes it easy for developers to obtain the gateway update list from the version management system and add, modify, and delete gateways.
[0091] There are situations where a gateway is added, its IP address or port is modified, or it is deleted. For a newly added gateway, the method provided in the embodiment of the present application is directly adopted to allocate an unused proxy port to it.
[0092] Assume that in addition to the newly added gateway, the port or IP address of the old gateway has changed. Since the old gateway has already been assigned a proxy port, there is no need to assign a proxy port. The gateway IP address and port number in the latest gateway list are the modified gateway information. The gateway update list can directly use the gateway information in the latest gateway list to generate a new proxy configuration file for dynamic proxy updates.
[0093] If a gateway is deleted, the gateway information will be deleted from the latest gateway list. The gateway update list can directly use the gateway information in the latest gateway list to generate a new proxy configuration file and perform a dynamic proxy update. As a result, the proxy port originally corresponding to the gateway becomes an unassigned proxy port again.
[0094] In one embodiment, if Figure 8 As shown, the above step S330 specifically includes: step S801-step S802.
[0095] Step S801: receiving, through a proxy server, a message sent by the client to a designated proxy port according to the gateway update list.
[0096] Specifically, the nginx service of the proxy server receives a message sent by the client to the designated proxy port based on the https protocol according to the gateway update list.
[0097] Step S802: forwarding the message to the designated port of the designated gateway corresponding to the gateway address and the gateway port identifier indicated in the proxy configuration file through the proxy server according to the gateway address and the gateway port identifier corresponding to the designated proxy port indicated in the proxy configuration file.
[0098] The nginx service of the proxy server forwards the message to the designated port of the designated gateway corresponding to the gateway address and the gateway port identifier based on the http protocol according to the gateway address and the gateway port identifier corresponding to the proxy port indicated in the proxy configuration file.
[0099] The solution provided by the embodiment of the present application is that all gateways are managed using a gatelist file, which defines the ip and port of each gateway. Previously, the client and the gateway were directly connected according to the ip and port. The developer of this application can add, delete, and modify the ip and port of the gateway by modifying the gatelist. The proxy server can replace the ip with the domain name of the proxy server, and can automatically assign an unused proxy port to the newly added gateway. At the same time, for distinction, the original ip and port of the gateway can be marked as real_ip and real_port. Generate a proxy configuration file according to the modified gatelist (i.e., gateway update list). The proxy server uses nginx for proxy, and updates the configuration after each regeneration of the proxy configuration. After the above steps, the client directly connects to the ip and port of the proxy server. After receiving the request, the nginx of the proxy server forwards according to the real_ip and real_port of the proxy configuration. Other developers do not need to care about the proxy, and can still configure and develop according to the original habits. In the case of other developers not being aware, let the internal service gateway support https access.
[0100] The following is an embodiment of the device of the present application, which can be used to execute the above-mentioned gateway proxy method embodiment of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the gateway proxy method embodiment of the present application.
[0101] Fig. 9 FIG. 1 is a block diagram of a proxy device of a gateway according to an embodiment of the present application. Fig. 9 As shown, the device is applied to a proxy server, and the device includes: a list pulling module 910 , a port allocation module 920 and a message forwarding module 930 .
[0102] A list pulling module 910 is used to pull the latest gateway list from the version management system and compare the latest gateway list with the historical gateway list;
[0103] The port allocation module 920 is used to allocate an unused proxy port to a target gateway to which no proxy is allocated according to the latest gateway list if the latest gateway list is different from the historical gateway list, and record a mapping relationship between the target gateway and the proxy port;
[0104] The message forwarding module 930 is used to receive a message sent by a client to a designated proxy port, and forward the message to a designated gateway corresponding to the designated proxy port according to a mapping relationship between each gateway and the proxy port.
[0105] In one embodiment, the list pulling module 910 is specifically used to periodically pull the latest gateway list from the version management system through an installed monitoring program.
[0106] In one embodiment, the list pulling module 910 is specifically used to: calculate the first information digest value of the latest gateway list and the second information digest value of the historical gateway list; compare whether the first information digest value is consistent with the second information digest value, and if not, determine that the latest gateway list is different from the historical gateway list.
[0107] In one embodiment, the port allocation module 920 includes: a list update unit, which is used to generate a gateway update list according to the proxy port assigned to each gateway; the gateway update list includes the communication address of the proxy server, multiple proxy port identifiers, and the gateway address and gateway port identifier corresponding to each proxy port identifier.
[0108] In one embodiment, the device further comprises:
[0109] A configuration generation module is used to generate a proxy configuration file for the nginx service according to the gateway update list;
[0110] The dynamic update module is used to establish a new process to establish the https service according to the proxy configuration file and close the old process corresponding to the historical gateway list.
[0111] In one embodiment, the device further includes: a list updating module, configured to replace the historical gateway list with the gateway update list.
[0112] In one embodiment, the device further includes: a list sending module, configured to send the gateway update list to the client and the version management system.
[0113] In one embodiment, the message forwarding module 930 includes:
[0114] A message receiving unit, configured to receive a message sent by the client to a designated proxy port according to the gateway update list;
[0115] The message forwarding unit is used to forward the message to the designated port of the designated gateway corresponding to the gateway address and the gateway port identifier according to the gateway address and the gateway port identifier corresponding to the designated proxy port indicated in the proxy configuration file.
[0116] In one embodiment, the message receiving unit is specifically used to: receive, through the nginx service, a message sent by the client to a designated proxy port based on the https protocol according to the gateway update list.
[0117] In one embodiment, the message forwarding unit is specifically used to: forward the message based on the http protocol to the designated port of the designated gateway corresponding to the gateway address and gateway port identifier corresponding to the proxy port indicated in the proxy configuration file through the nginx service.
[0118] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the proxy method of the above-mentioned gateway, and will not be repeated here.
[0119] In several embodiments provided in the present application, the disclosed devices and methods may also be implemented in other ways. The device embodiments described above are merely schematic, for example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram may represent a module, a program segment or a part of a code, and a module, a program segment or a part of a code contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they may sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0120] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0121] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.
Claims
1. A gateway proxy method, characterized in that: The method is applied to a proxy server, where an https certificate is deployed, and the method comprises: Pull the latest gateway list from the version management system through the proxy server, and compare the latest gateway list with the historical gateway list; If the latest gateway list is different from the historical gateway list, assigning an unused proxy port to a target gateway to which no proxy is assigned according to the latest gateway list, and recording a mapping relationship between the target gateway and the proxy port; The message sent by the client to the designated proxy port is received through https, and according to the mapping relationship between each gateway and the proxy port, the message is forwarded to the designated gateway corresponding to the designated proxy port through the http protocol.
2. The method according to claim 1, characterized in that Pulling the latest gateway list from the version management system through the proxy server includes: The monitoring program installed on the proxy server periodically pulls the latest gateway list from the version management system.
3. The method according to claim 1, characterized in that The comparing the latest gateway list with the historical gateway list includes: Calculate the first information digest value of the latest gateway list and the second information digest value of the historical gateway list by the proxy server; Compare the first information digest value and the second information digest value to see if they are consistent, and if they are inconsistent, determine that the latest gateway list is different from the historical gateway list.
4. The method according to claim 1, characterized in that: The recording of the mapping relationship between the target gateway and the proxy port includes: The proxy server generates a gateway update list according to the proxy port correspondingly allocated to each gateway; the gateway update list includes the domain name of the proxy server, multiple proxy port identifiers, and the gateway address and gateway port identifier corresponding to each proxy port identifier.
5. The method according to claim 4, characterized in that After generating the gateway update list, the method further includes: Generate a proxy configuration file for the nginx service through the proxy server according to the gateway update list; A new process is established to establish the https service according to the proxy configuration file, and the old process corresponding to the historical gateway list is closed.
6. The method according to claim 4, characterized in that After generating the gateway update list, the method further includes: The proxy server uses the gateway update list to replace the historical gateway list.
7. The method according to claim 4, characterized in that After generating the gateway update list, the method further includes: The gateway update list is sent to the client and the version management system through the proxy server.
8. The method according to claim 7, characterized in that The receiving a message sent by the client to the designated proxy port through https, and forwarding the message to the designated gateway corresponding to the designated proxy port through http protocol according to the mapping relationship between each gateway and the proxy port, comprises: Receiving, through the proxy server, a message sent by the client to a designated proxy port according to the gateway update list; The proxy server forwards the message to the designated port of the designated gateway corresponding to the gateway address and the gateway port identifier according to the gateway address and the gateway port identifier corresponding to the designated proxy port indicated in the proxy configuration file.
9. The method according to claim 8, characterized in that The receiving, through the proxy server, a message sent by the client to the designated proxy port according to the gateway update list comprises: The message sent by the client to the designated proxy port based on the https protocol according to the gateway update list is received through the nginx service of the proxy server.
10. The method according to claim 8, characterized in that The method of forwarding the message to a designated port of a designated gateway corresponding to the gateway address and the gateway port identifier by the proxy server according to the gateway address and the gateway port identifier corresponding to the designated proxy port indicated in the proxy configuration file includes: The message is forwarded to the designated port of the designated gateway corresponding to the gateway address and the gateway port identifier based on the http protocol through the nginx service of the proxy server according to the gateway address and the gateway port identifier corresponding to the proxy port indicated in the proxy configuration file.
11. A proxy device for a gateway, characterized in that: The device is applied to a proxy server, the proxy server is deployed with an https certificate, and the device includes: A list pulling module is used to pull the latest gateway list from the version management system and compare the latest gateway list with the historical gateway list; A port allocation module, configured to allocate an unused proxy port to a target gateway to which no proxy is allocated, and record a mapping relationship between the target gateway and the proxy port according to the latest gateway list if the latest gateway list is different from the historical gateway list; The message forwarding module is used to receive a message sent by a client to a designated proxy port through https, and forward the message to a designated gateway corresponding to the designated proxy port through http protocol according to the mapping relationship between each gateway and the proxy port.
12. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing processor-executable instructions; The processor is configured to execute the gateway proxy method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and the computer program can be executed by a processor to complete the proxy method of the gateway according to any one of claims 1-10.
