Disclosure of Invention
The invention provides a service background identification method, a proxy server and a computer storage medium, which are used for solving the technical problem of overhigh cost of the proxy server in the prior art.
In a first aspect of the embodiments of the present invention, a service background identification method is provided, which is applied to a proxy server, and includes: obtaining a first service ID value based on a first service request from customer premise equipment; and determining first address information of a first service background corresponding to the first service ID value from at least two pieces of address information of at least two background services based on a background service list containing a corresponding relation among the service ID value, the service identifier and the address information of the service background.
With reference to the first aspect, in a first possible implementation manner of the first aspect, the obtaining a first service ID value based on a first service request from a customer premise equipment includes: judging whether a cookie of the first service request has a first service ID item or not; wherein the first service ID item is to store a first service ID value determined based on a first operation; if so, reading the first service ID entry to obtain the first service ID value.
With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, after the determining whether there is the first service ID entry in the cookie of the first service request, the method further includes: if not, returning response information based on the first service request to the user equipment end; and the response information comprises a user background service list of the corresponding relation between the service identification and the service ID value.
With reference to the first aspect, in a third possible implementation manner of the first aspect, after the determining, based on a background service list including a correspondence between a service ID value and address information of a service background, first address information of a first service background corresponding to the first service ID value from at least two address information of at least two background services, the method further includes: modifying the address information of the proxy server in the first service request to the first address information to obtain a first modified service request; sending the first modified service request to the first service backend.
With reference to the third possible implementation manner of the first aspect, in a fourth possible implementation manner of the first aspect, after the sending the first modified service request to the first service background, the method further includes: receiving first service response information returned by the first service background based on the first modified service request; judging whether a Set-Cookie item exists in a response header of the first service response information; if yes, obtaining the first service identification from the background service list based on the first address information; inserting the first service identification into the response header to obtain first response information; returning the first response information to the customer premise equipment; if not, inserting the Set-Cookie item with the first service identifier into the response head to obtain second response information; and returning the second response information to the customer premise equipment.
In a second aspect of the embodiments of the present invention, a proxy server is provided, including: an obtaining unit, configured to obtain a first service ID value based on a first service request from a user end device; the determining unit is used for determining first address information of a first service background corresponding to the first service ID value from at least two pieces of address information of at least two background services based on a background service list containing a corresponding relation among the service ID value, the service identifier and the address information of the service background.
With reference to the second aspect, in a first possible implementation manner of the second aspect, the obtaining unit includes: a judging subunit, configured to judge whether a cookie of the first service request has a first service ID item; wherein the first service ID item is to store a first service ID value determined based on a first operation; an obtaining subunit, configured to, if yes, read the first service ID entry to obtain the first service ID value.
With reference to the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the proxy server further includes: a sending unit, configured to, if the first service request is received, send response information based on the first service request back to the user equipment; and the response information comprises a user background service list of the corresponding relation between the service identification and the service ID value.
With reference to the second aspect, in a third possible implementation manner of the second aspect, the proxy server further includes: a modifying unit, configured to modify address information of the proxy server in the first service request into the first address information, so as to obtain a first modified service request; a sending unit, configured to send the first modified service request to the first service background.
With reference to the third possible implementation manner of the second aspect, in a fourth possible implementation manner of the second aspect, the proxy server further includes: a receiving unit, configured to receive first service response information returned by the first service background based on the first modified service request; a judging unit, configured to judge whether a Set-Cookie item exists in a response header of the first service response information; if yes, obtaining the first service identification from the background service list based on the first address information; inserting the first service identification into the response header to obtain first response information; returning the first response information to the customer premise equipment; if not, inserting the Set-Cookie item with the first service identifier into the response head to obtain second response information; and returning the second response information to the customer premise equipment.
In a third aspect of embodiments of the present invention, a computer-readable storage medium is provided, which includes instructions that, when executed on a computer, cause the computer to perform the method according to any one of the first to fourth possible implementation manners of the first aspect.
Through the technical solutions in one or more of the above embodiments of the present invention, the embodiments of the present invention have at least the following technical effects:
1. in the embodiment provided by the application, the service type requested by the user can be quickly identified through a background service list and a first service ID value, so that the proxy server can accurately identify the service background required by the user from the multi-service background, and then the user can obtain the data of all service backgrounds by accessing 1 proxy server, thereby improving the user experience; furthermore, the enterprise can proxy all the services of the service background through 1 proxy server, thereby effectively reducing the hardware cost.
2. In the embodiment provided by the application, the cookie is used to enable the first service request of the user to carry the first service ID value, so that the proxy server can easily determine the requirement of the user by reading the first service ID value, and the cookie is actually generated by the proxy server and then sent to the browser of the user equipment terminal, and the cookie is small information not exceeding 4kb, so that the proxy server can provide diversified services for the user only by transmitting a small amount of information in the process of performing various business services for the user, and further the user experience is effectively improved.
3. In the embodiment provided by the application, the first service request of the user can be quickly forwarded by only modifying the address information of the proxy server in the first service request sent by the user into the first address information of the first background service, so that the system resources of the proxy server are effectively saved, and the working efficiency is improved. Furthermore, before forwarding the first service request of the user to the first background service, the proxy server modifies the address information of the proxy server in the first service request to be first address information in advance, so that the first background service is always in communication with the proxy server only, thereby achieving the technical effect of maintaining the original business process of the first background service.
4. In the embodiment provided by the application, whether a Set-Cookie item exists in a response header of first service response information of a first service background is automatically judged by the proxy server, the first service identifier is inserted when the Set-Cookie item exists to obtain first response information, the Set-Cookie item with the first service identifier is inserted when the Set-Cookie item does not exist to obtain second response information, and then the first response information or the second response information is returned to a user equipment terminal. The whole modification process is independently completed by the proxy server, so that the technical effect of not changing the original business process is realized when the first background service returns the first service response information.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention will be described in further detail with reference to the accompanying drawings.
The techniques described herein are not limited to use with servers, but may also be used with computers, workstations, mainframes, kiosks, server racks, and the like.
First, a technical background of an embodiment of the present invention is described.
In the prior art, in order to ensure the safety of the service backgrounds and provide services for users efficiently, a proxy server is generally configured for each service background, and a user accesses the proxy server, then makes the proxy server replace the access service background and forwards response data to the user, so as to obtain data of the service background.
At present, the proxy server is only responsible for forwarding data, and usually only can identify a single service background, and with the increasing and diversified demands of users, various new services are increasing, the service backgrounds configured for the new services are also increasing, and the proxy servers matched with the new services are also increasing, so that the hardware cost of enterprises is also increasing. Therefore, with the increasing business types of enterprises, the hardware cost is increased.
In view of this, in the embodiment of the present invention, only one background service list is established in the proxy server, the background service list at least includes address information of all service backgrounds, a corresponding service ID value is compiled for each address information in the table, when the user performs the first operation, the service requirement of the user is converted into the service ID value, and the proxy server determines, through the service ID value and the background service list, the address information corresponding to the service required by the user, and further accesses the service background corresponding to the address information. The embodiment of the invention quickly identifies the service type requested by the user and determines the service background through the corresponding relation between the service ID value and the address information of the service background in the background service list, thereby simultaneously acting multiple service backgrounds by using one agent server and further achieving the aim of effectively saving the cost.
The technical scheme provided by the embodiment of the invention is described below by combining the accompanying drawings.
Referring to fig. 1, an embodiment of the present invention provides a method for identifying a service background, where the method includes the following processing procedures.
Step 101: a first service ID value is obtained based on a first service request from a customer premises device.
When a user browses a page of the proxy server, a first service request is generated by clicking a service on the page, and the proxy server obtains a first service ID value from the received first service request.
For example, when a user browses the top page of a new wave, click on a "video" service on the page to generate request information that a first service request is a video service, the first service ID value corresponding to the video service is 001, the request information of the first service request includes a value that the first service ID value is ADBC001, and after receiving the first service request, the proxy server reads the first service ID value ADBC001 from the first service request.
Step 102: and determining first address information of a first service background corresponding to the first service ID value from at least two pieces of address information of at least two background services based on a background service list containing a corresponding relation among the service ID value, the service identifier and the address information of the service background.
After the proxy server obtains the first service ID value, first address information corresponding to the first service ID value is found from a background service list stored in the proxy server, and then a first service background is identified.
Continuing with the above example, an exemplary list of background services is shown in Table 1.
TABLE 1
Service identification
|
Service ID
|
Address information
|
Video service
|
ADBC001
|
adress1
|
Microblog service
|
ADBC002
|
adress2
|
Blog service
|
ADBC003
|
adress3
|
Sports service
|
ADBC004
|
adress4
|
Shopping service
|
ADBC005
|
adress5 |
After obtaining the first service ID value ADBC001, the proxy server searches whether there is ADBC001 in the service ID of the background service list, and reads address information corresponding to ADBC001 as adress1 after finding, at this time, the proxy server identifies that the address information of the first service background corresponding to the service needed by the user is adress1 from a plurality of service backgrounds, and then sends a service request to the first service background.
In the embodiment provided by the application, the service type requested by the user can be quickly identified through a background service list and a first service ID value, so that the proxy server can accurately identify the service background required by the user from the multi-service background, and then the user can obtain the data of all service backgrounds by accessing 1 proxy server, thereby improving the user experience; furthermore, the enterprise can proxy all the services of the service background through 1 proxy server, thereby effectively reducing the hardware cost.
In one embodiment, the obtaining a first service ID value based on a first service request from a customer premises device includes:
judging whether a cookie of the first service request has a first service ID item or not; wherein the first service ID item is to store a first service ID value determined based on a first operation;
if so, reading the first service ID entry to obtain the first service ID value.
In the Internet, a cookie (browser cache) actually refers to a small amount of information not exceeding 4kb, and is generated by a server side and sent to the browser, the browser saves the key/value of the cookie in a text file under a certain directory, and the cookie is sent to the server next time the same website is requested.
When the proxy server receives the first service request, whether a first service ID item written in advance by the proxy server exists in a cookie of the first service request is judged, and when the first service ID item exists, the value of the first service ID item is read, so that the first service ID value is obtained.
It should be noted that the first service ID item can be understood as a variable for storing the first service ID value determined based on the first operation of the user.
In the embodiment provided by the application, the cookie is used to enable the first service request of the user to carry the first service ID value, so that the proxy server can easily determine the requirement of the user by reading the first service ID value, and the cookie is actually generated by the proxy server and then sent to the browser of the user equipment terminal, and the cookie is small information not exceeding 4kb, so that the proxy server can provide diversified services for the user only by transmitting a small amount of information in the process of performing various business services for the user, and further the user experience is effectively improved.
In one embodiment, after determining whether the cookie of the first service request has the first service ID entry, the method further comprises:
if not, returning response information based on the first service request to the user equipment end; and the response information comprises a user background service list of the corresponding relation between the service identification and the service ID value.
When the user accesses the proxy server for the first time, the device side of the user does not store a user background service list generated by the proxy server, wherein the user background service list is the service identifier and the service ID value part in the background service list. Therefore, the first service ID entry does not exist in the first service request generated when the user performs the first operation on the page of the proxy server, and at this time, the proxy server needs to send the user background service list and the JS (javascript) script to the user equipment.
Further, after receiving the user background service list, the browser at the user equipment displays the service identifiers in the user background service list in the page, and when the user performs a first operation on one of the service identifiers in the page, the browser determines that the service ID value corresponding to the user background service list is the first service ID value, and further triggers a JS (javascript) script to generate a first service request including the first service ID value, and sends the first service request to the proxy server.
In one embodiment, after determining, from at least two pieces of address information of at least two background services, first address information of a first service background corresponding to a first service ID value based on a background service list including a correspondence between the service ID value and address information of the service background, the method further includes:
modifying the address information of the proxy server in the first service request to the first address information to obtain a first modified service request;
sending the first modified service request to the first service backend.
After the proxy server determines first address information of a first service background corresponding to the first service ID value from at least 2 address information of at least 2 background services through the first service ID value, the address information of the proxy server in the first service request sent by a user equipment end is modified into the first address information of the first service background, and then a first modified service request which can be sent to the first service background is obtained.
For example, assuming that the address information of the proxy server is www.proxyserver.com and the address information of the first service background is www.server001.com, when the URL in the header information of the first service request sent by the user equipment to the proxy server is www.proxyserver.com, that is, the network layer of the user equipment finds the proxy server through www.proxyserver.com, after the proxy server receives the first service request, it determines the first address information corresponding to the first service ID value by searching whether the first service ID value carried in the first request information exists in the background service list.
In the embodiment provided by the application, the first service request of the user can be quickly forwarded by only modifying the address information of the proxy server in the first service request sent by the user into the first address information of the first background service, so that the system resources of the proxy server are effectively saved, and the working efficiency is improved. Furthermore, before forwarding the first service request of the user to the first background service, the proxy server modifies the address information of the proxy server in the first service request to be first address information, so that the first background service always communicates with the proxy server only, thereby maintaining the original business process of the first background service.
In one embodiment, after said sending said first modified service request to said first service background, said method further comprises:
receiving first service response information returned by the first service background based on the first modified service request;
judging whether a Set-Cookie item exists in a response header of the first service response information;
if yes, obtaining the first service identification from the background service list based on the first address information; inserting the first service identification into the response header to obtain first response information; returning the first response information to the customer premise equipment;
if not, inserting the Set-Cookie item with the first service identifier into the response head to obtain second response information; and returning the second response information to the customer premise equipment.
When the first service background receives the first modified request sent by the proxy server, corresponding first service response information is sent to the proxy server according to the request. Since the first service response information is generated for the first service request sent by the user, the proxy server also needs to forward the first service response information to the user equipment.
However, the Set-Cookie item may be included or not included in the first service response information sent by the first service background, and only the response information of the Set-Cookie item including the first service identifier corresponding to the first service request can be identified by the user equipment, so that the proxy server needs to determine whether the Set-Cookie item exists in the first response information.
When the judgment result shows that the response header of the first service response information contains a Set-Cookie item, the proxy server needs to insert a first service identifier corresponding to a first service ID value in the background service list into the Set-Cookie item to form first response information, and returns the first response information to the user equipment end, so that the user equipment end can obtain the first service response information of the first service background.
And when the judgment result shows that the response header of the first service response information does not contain the Set-Cookie item, the proxy server needs to insert the Set-Cookie item carrying the first service identifier into the response header of the first response information to form second response information, and returns the second response information to the user equipment terminal, so that the user equipment terminal can obtain the first service response information of the first service background.
In the embodiment provided by the application, whether a Set-Cookie item exists in a response header of first service response information of a first service background is automatically judged by the proxy server, the first service identifier is inserted when the Set-Cookie item exists to obtain first response information, the Set-Cookie item with the first service identifier is inserted when the Set-Cookie item does not exist to obtain second response information, and then the first response information or the second response information is returned to a user equipment terminal. The whole modification process is independently completed by the proxy server, so that the original business process of the first background service does not need to be changed when the first background service returns the first service response information.
Referring to fig. 2, based on the same inventive concept, an embodiment of the present invention provides a proxy server, which includes a processing unit 201, a receiving unit 202, and a sending unit 203.
The processing unit 201 may include a Central Processing Unit (CPU) or an Application Specific Integrated Circuit (ASIC), may include one or more Integrated circuits for controlling program execution, and may include a hardware Circuit developed using a Field Programmable Gate Array (FPGA).
In a possible embodiment, the processing unit 201 is configured to obtain a first service ID value based on a first service request from a customer premises device; the processing unit 201 is further configured to determine, from at least two pieces of address information of at least two background services, first address information of a first service background corresponding to the first service ID value, based on a background service list including a correspondence between the service ID value and the address information of the service background.
In a possible embodiment, the processing unit 201 is further configured to determine whether there is a first service ID entry in a cookie of the first service request; wherein the first service ID item is to store a first service ID value determined based on a first operation; the processing unit 201 is further configured to, if yes, read the first service ID entry to obtain the first service ID value.
In a possible embodiment, the method further includes a sending unit 203, configured to, if no, return response information based on the first service request to the user equipment; and the response information comprises a user background service list of the corresponding relation between the service identification and the service ID value.
In a possible embodiment, the processing unit 201 is further configured to modify the address information of the proxy server in the first service request into the first address information to obtain a first modified service request; a sending unit 203, further configured to send the first modified service request to the first service background.
In a possible implementation, the receiving unit 202 is configured to receive first service response information returned by the first service background based on the first modified service request; the processing unit 201 is further configured to determine whether a Set-Cookie item exists in a response header of the first service response information; if yes, obtaining the first service identification from the background service list based on the first address information; inserting the first service identification into the response header to obtain first response information; the sending unit 203 is configured to return the first response information to the customer premises equipment; the processing unit 201 is further configured to, if the response header is not the first service identifier, insert a Set-Cookie item with the first service identifier into the response header to obtain second response information; the sending unit 203 is configured to return the second response information to the customer premises equipment.
An embodiment of the present invention further provides a computer storage medium, where the computer storage medium may store a program, and the program includes all the steps executed by the proxy server described in the method embodiment shown in fig. 1 when executed.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.