CN111478935B - Resource access method, internetwork connecting device, system and device - Google Patents
Resource access method, internetwork connecting device, system and device Download PDFInfo
- Publication number
- CN111478935B CN111478935B CN201911294600.2A CN201911294600A CN111478935B CN 111478935 B CN111478935 B CN 111478935B CN 201911294600 A CN201911294600 A CN 201911294600A CN 111478935 B CN111478935 B CN 111478935B
- Authority
- CN
- China
- Prior art keywords
- resource
- access request
- http
- information
- resource access
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 33
- 230000003068 static effect Effects 0.000 claims description 17
- 230000000977 initiatory effect Effects 0.000 claims description 7
- 230000006870 function Effects 0.000 description 13
- 230000009471 action Effects 0.000 description 8
- 238000010586 diagram Methods 0.000 description 7
- 230000008859 change Effects 0.000 description 4
- 238000012423 maintenance Methods 0.000 description 3
- 230000007246 mechanism Effects 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 238000011045 prefiltration Methods 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 2
- 239000003795 chemical substances by application Substances 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 239000012634 fragment Substances 0.000 description 2
- 230000004044 response Effects 0.000 description 2
- VYZAMTAEIAYCRO-UHFFFAOYSA-N Chromium Chemical compound [Cr] VYZAMTAEIAYCRO-UHFFFAOYSA-N 0.000 description 1
- 230000008676 import Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/02—Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/60—Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
- H04L67/63—Routing a service request depending on the request content or context
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The application discloses a resource access method, an internetwork connecting device, a system and a device. The method is used for the internetwork connecting device and comprises the following steps: acquiring header information in the HTTP resource access request; searching for matched target micro-services according to the header information; and sending the HTTP resource access request to a target micro service so as to access the target webpage resource corresponding to the HTTP resource access request. By the mode, the access of the webpage resources is realized by utilizing the internetwork connecting device, and the resource access system architecture is simplified.
Description
Technical Field
The present application relates to the field of internet technologies, and in particular, to a resource access method, an internetwork connection device, a system, and an apparatus.
Background
Micro service Architecture (micro service Architecture) is an Architecture mode, which provides final value for users by dividing a single application into a set of small services, and coordinating and cooperating the services.
At present, the micro-service architecture is applied in a large scale due to the characteristics of light weight, flexibility, easy deployment and the like, and more applications are migrated to the micro-service architecture. However, the introduction of the micro-service also brings great complexity to the front-end client to call the back-end service, and because the front-end client needs to be connected with a plurality of micro-service addresses of the back-end, the change of any micro-service may affect the front-end client, and the change causes the front-end client to be difficult to maintain, so that the micro-service gateway Zuul needs to be adopted to realize the proxy of the micro-service.
Typically, the front-end client sends an HTTP resource access request to the gateway requesting to obtain a browser page, and then proxies to the corresponding microservice by the gateway, thereby converging the change in microservices to the layer of the gateway. However, some browser pages include multiple levels of web resources, such as the H5 page including HyperText Markup Language (HTML) files and other web resources referenced under HTML files. When the resource accessed by the HTTP resource access request is a web resource referred by an HTML file, the existing gateway cannot identify which micro-service the HTTP resource access request belongs to according to the URL address in the HTTP resource access request, which may cause routing failure and may not load a related web resource.
Disclosure of Invention
The technical problem mainly solved by the application is to provide a resource access method, an internetwork connecting device, a system and a device, which can realize the access of webpage resources by using the internetwork connecting device and simplify the architecture of a resource access system.
In order to solve the technical problem, the application adopts a technical scheme that: provided is a resource access method, including: acquiring header information in the HTTP resource access request; searching for matched target micro-services according to the header information; and sending the HTTP resource access request to a target micro service so as to access the target webpage resource corresponding to the HTTP resource access request.
In order to solve the above technical problem, another technical solution adopted by the present application is: provided is an internetworking connection device, including: the head acquirer is used for acquiring the head information in the HTTP resource access request; the route finder is used for finding the matched target micro-service according to the head information; and the request forwarder is used for sending the HTTP resource access request to the target micro service so as to access the target webpage resource corresponding to the HTTP resource access request.
In order to solve the above technical problem, the present application adopts another technical solution: there is provided a resource access system provided with a plurality of microservices and configured with an internetworking unit as described above.
In order to solve the above technical problem, the present application adopts another technical solution that: there is provided a storage device having instructions stored thereon that, when executed by a processor, perform the steps of the above-described resource access method.
The beneficial effect of this application is: different from the prior art, the internetworking connection device in the application can acquire the header information in the HTTP resource access request; searching for matched target micro-services according to the header information; the HTTP resource access request is sent to the target micro-service to access the target webpage resource corresponding to the HTTP resource access request, so that the webpage resource access by utilizing the internetwork connecting device is realized, the access of different levels of webpage resources can be realized for multi-level webpage resources, in addition, the access of the webpage resources can be realized by directly utilizing the internetwork connecting device, other proxy servers are not required to be additionally added, and the resource access system architecture can be simplified.
Drawings
FIG. 1a is a schematic flow chart diagram illustrating an embodiment of a resource access method of the present application;
FIG. 1b is a schematic diagram of an embodiment of a resource access system of the present application;
FIG. 2 is a schematic flow chart diagram illustrating another embodiment of a resource access method of the present application;
FIG. 3 is a schematic view of an embodiment of an inter-network connection apparatus according to the present application;
FIG. 4 is a schematic structural diagram of an embodiment of a memory device according to the present application.
Detailed Description
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 of 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.
For some browser pages, multiple levels of web page resources may be included, for example, an H5 page is composed of files such as HTML (hypertext markup language), Cascading Style Sheets (CSS), pictures (e.g., pictures in the format of JPG, PNG, GIF, SVG), fonts, JavaScript (JS for short), and the like, the HTML file is a first level web page resource, the files such as CSS, JS, pictures, fonts and the like are lower level web page resources of the HTML file, and the CSS file can continuously load other web page resources, so there may be still another lower level web page resources such as CSS, pictures, and the like under the CSS file. Generally, the WebView component is a component used for displaying and running H5 pages in an Android system APP and an iOS system APP. Specifically, a WebView component of a front-end client loads an HTML file first, that is, sends an HTTP resource access request including a resource access address of the HTML file to an internetwork connection device (a gateway described herein is a micro service gateway such as Zuul) to request the internetwork connection device to forward to a corresponding micro service to obtain the HTML file; then, continuously loading referenced files such as CSS, JS and pictures according to the path in the HTML file, namely, sending an HTTP resource access request containing resource access addresses of the files such as CSS, JS and pictures to the internetwork connecting device to request the internetwork connecting device to forward to corresponding microservices to obtain the files such as CSS, JS and pictures; by analyzing the reference path in the CSS file, other CSS files, pictures, font files and the like referenced in the CSS file are continuously loaded, namely, an HTTP resource access request containing resource access addresses of the other CSS files and the picture files is sent to the internet connection device to request the internet connection device to forward to the corresponding microservices to obtain the other CSS files and the picture files. The Resource access address described in the present application may be an address that enables access to a corresponding Resource, and specifically may be a Uniform Resource Locator (URL) address, which is described below by taking the URL address as an example.
For a browser page containing multi-level webpage resources, when a URL (uniform resource locator) address containing first-level webpage resources such as HTML (hypertext markup language) is received, the conventional internetwork connecting device can directly determine related micro-services according to the URL address so as to access and obtain corresponding resources; when the resource file is a non-top-level webpage resource of an HTML file such as a CSS, a JS, a picture, a font and the like, the existing internetwork connecting device cannot determine related micro-services according to the URL address so as to access the corresponding resource, at the moment, a mode is adopted that an Nginx server can be added between the internetwork connecting device and the front end, the Nginx can be used as a forward proxy and a reverse proxy of the webpage resource, and the URL address of the webpage resource is rewritten through the URL rewriting function of the Nginx so as to realize proxy access of the webpage resource.
However, the manner of adding the Nginx server is equivalent to introducing a new component into the resource access system architecture, so that the complexity of the architecture is increased, the response time and the reliability of request processing are also increased, and when the resource access system architecture is changed, the configuration file of the Nginx needs to be manually modified, so that the URL rewrite rule of the Nginx can be modified, the complexity of operation and maintenance of the resource access system architecture is increased, and an error is easy to occur in the manual modification process; in addition, because the URL rewriting of the nginnx depends on the current request context path, when the current requested web resource is a non-top level web resource, such as a web resource referenced under a CSS file, since the path of the top level web resource, such as an HTML file, is lost, the current requested URL cannot be rewritten at this time, thereby causing agent failure; in addition, because there are various ways for the CSS file to refer to the web page resource, such as @ import, URL, Link, etc., it is also difficult for the Nginx server to perform complete path rewriting on the resource reference in the CSS file, so the application scenario of the Nginx server is very limited.
Based on the above, the present application proposes to improve the internet connection device, so that the improved internet connection device can be used to realize access to the non-top level web resource and other web resources that cannot realize proxy access by using the resource access address in HTTP, without adding new components to the resource access system architecture, thereby simplifying the resource access system architecture. The present application is illustrated below with reference to various examples. The resource access method provided by the embodiment of the application can be used for an internetwork connecting device.
Referring to fig. 1a, fig. 1a is a schematic flowchart illustrating an embodiment of a resource access method according to the present application, where the method includes the following steps:
s10: and acquiring the header information in the HTTP resource access request.
Specifically, in some embodiments, it may be that the client sends an HTTP resource access request; in other embodiments, the HTTP resource access request may be sent by another gateway, or may be sent by another device, which is not limited to this. In this embodiment, an example in which a client transmits an HTTP resource access request is described. The gateway acquires header information in the HTTP resource access request. The header information includes path information corresponding to a superior web resource of the target web resource.
The client may be a browser client, an APP client, or the like, and the internetworking connection device may be a Zuul gateway. Zuul is an application gateway based on Java technology, and is used for forwarding the HTTP resource access request of the client to the back-end micro-service by reading the URL routing rule configuration, and returning the response of the back-end micro-service to the client to finish the proxy forwarding of the HTTP resource access request. In the resource access system architecture, Zuul is a unified entry of front-end HTTP traffic, and can be used to assume gateway proxy functions such as traffic forwarding, load balancing, and the like. When detecting an access instruction of a user to a browser page, a client starts to load webpage resources contained in the browser page. Optionally, the browser refers to a client program used by a user to access a website, and the browser in this embodiment may be an IE browser, a Firefox browser, a Chrome google browser, or the like.
Specifically, referring to fig. 1b in combination, fig. 1b shows a schematic structural diagram of an embodiment of the resource access system of the present application. The resource access system comprises at least one client 11, an internetwork connecting device 12 and a plurality of micro services 13, wherein each micro service 13 comprises a plurality of nodes 14, the nodes 14 of each client 11 and each micro service 13 are connected to the internetwork connecting device 12, the client 11 provides a user with webpage browsing, the resource access system comprises a plurality of micro services 13, each micro service 13 can correspond to at least one micro service node 14, different micro services 13 are used for obtaining different webpage resources (for example, the different micro services store the webpage resources themselves or can directly access a webpage resource pool to obtain the corresponding webpage resources), and the nodes 14 corresponding to the same micro service 13 can realize the functions of the micro service 13. In some applications, the same microservice 13 can acquire all web page resources under the same browser page. The client 11 forwards the HTTP resource access request to the node 14 corresponding to the microservice 13 through the internet connection device 12, and the node 14 finds the corresponding web resource according to the HTTP resource access request and forwards the web resource to the client 11 through the internet connection device 12. Taking the H5 page as an example, the client 11 sends an HTTP resource access request containing the resource access address of the HTML file to the internet connection apparatus 12 to request the internet connection apparatus 12 to forward to the node 14 of the corresponding microservice 13 to load the HTML file; then, sending an HTTP resource access request containing resource access addresses of the files such as the CSS, the JS and the pictures to the internet connection device 12 to request the internet connection device 12 to forward to the node 14 of the corresponding microservice 13 to load the files such as the CSS, the JS and the pictures; when the loaded CSS file also refers to another CSS file and a picture file, the HTTP resource access request including the resource access address of the other CSS file and the picture file is continuously transmitted to the internet connection apparatus 12 to request the internet connection apparatus 12 to forward to the node 14 of the corresponding microservice 13 to load the other CSS file and the picture file. Therefore, the process that the client 11 sends the HTTP resource access request to the internet connection device 12 each time to request the internet connection device 12 to forward to the node 14 of the corresponding microservice 13 to load the relevant web resource is realized by the internet connection device 12 by executing the method of the embodiment of the present application.
S11: and searching the matched target micro-service according to the header information.
Alternatively, the matching target microservice can be searched according to the header Referer information in the header information. Of course, the matched target microservice can also be found according to other header information, which is not limited herein.
The header refer information may include path information corresponding to a higher-level web resource of the target web resource, where the higher-level web resource may be understood as any level of web resource located before the target web resource in the same browser page, for example, a first level of web resource in the same browser page or a last level of web resource located before the target web resource in the same browser page. For example, if the target web page resource is a picture file referenced under a CSS file in a H5 page, the header Referer information may include path information of the CSS file in the H5 page, and/or directly include path information of an HTML file in the H5 page.
For example, the target web resource of the HTTP resource access request is a CSS file of a non-top level web resource, and the gateway device cannot determine the target micro-service according to the primary access address in the HTTP resource access request, so that header refer information in the HTTP resource access request needs to be acquired, such as HTTP:// www.xxxx.com/userinfo/a.html. The header Referer information includes path information userinfo corresponding to a first-level web resource HTML file of a page where the CSS file is located. Since the web page resources of the same browser page are from the same microservice, the internet connection device can find out the microservice associated with the path information userinfo as the target microservice.
S12: and sending the HTTP resource access request to a target micro service so as to access the target webpage resource corresponding to the HTTP resource access request.
It is to be understood that the resource access system architecture of the present application may include a plurality of microservices, each microservice corresponding to a plurality of nodes to implement the microservices. Therefore, in all embodiments of the present application, when forwarding the HTTP resource access request to the node corresponding to the target micro-service, the internetworking connection device may forward the HTTP resource access request to the node corresponding to the target micro-service by using a load balancing policy. For example, the internetwork connection device selects a current idle node from a plurality of nodes corresponding to the target micro-service by using a load balancing strategy, and forwards the HTTP resource access request to the node, so that the node searches for the target web page resource and feeds back the target web page resource to the internetwork connection device. In a specific application, the internetwork connection device can use a load balancing component such as a Spring Cloud Ribbon component to realize the API call of the micro-service, the Ribbon has the client load balancing capability, can automatically discover the nodes of the micro-service, and forwards the request to the most appropriate nodes of the micro-service for processing through a client load balancing algorithm.
In this embodiment, the internet connection device can acquire header information in the HTTP resource access request; searching for matched target micro-services according to the header information; the HTTP resource access request is sent to the target micro-service to access the target webpage resource corresponding to the HTTP resource access request, so that the webpage resource access by utilizing the internetwork connecting device is realized, the access of different levels of webpage resources can be realized for multi-level webpage resources, in addition, the access of the webpage resources can be realized by directly utilizing the internetwork connecting device, other proxy servers are not required to be additionally added, and the resource access system architecture can be simplified.
Referring to fig. 2, fig. 2 is a schematic flow chart showing another embodiment of the resource access method of the present application, which includes the following steps:
s20: and judging whether the matched target micro service can be found according to the primary access address in the HTTP resource access request.
If the matching target micro-service can be found, step S21 is executed.
If the matching target micro-service cannot be found, step S22 is executed.
In particular, the primary access address may include a protocol, a hostname, a port number, a path, and the like. In one embodiment, the general syntax format for the primary access address is protocol:// hostname [: port ]/path/[; parameters ] [? query ] # fragment, where protocol denotes protocol, hostname denotes host name, [: port ] denotes port number, path denotes path, parameters denotes parameters, query denotes query, fragment denotes piece of information, where the content with brackets [ ] is optional. In general, a hostname refers to a Domain Name System (DNS) hostname or IP address of a server hosting a resource. A path is used to represent a directory or file address on a host. In this embodiment, the primary access address is a URL address.
For example, the internet connection device acquires an HTTP resource access request, wherein the HTTP resource access request comprises HTTP:// www.xxxx.com/action/b.css of a primary access address generated by the client for the target webpage resource CSS file. The protocol is http protocol, the host is www.xxxx.com, and the path is action/b.css, that is, the path action/b.css may be a directory or file address on host xxxx.
For a browser page containing multiple levels of web page resources, if a target web page resource requested to be accessed by an HTTP resource access request is a top level web page resource (e.g., an HTML file of an H5 page) of the browser page, since a primary access address in the HTTP resource access request can be directly used for determining a target micro-service (e.g., a path in the URL can directly point to the target micro-service), the inter-network connection device can directly determine the target micro-service according to the primary access address in the HTTP resource access request; if the target web page resource requested to be accessed by the HTTP resource access request is a non-top level web page resource of the browser page (e.g., a CSS, a JS, a picture, a font, and other files of an H5 page), since the primary access address in the HTTP resource access request cannot be directly used for determining the target microservice (e.g., the path in the URL cannot be directly directed to the target microservice), the inter-network connection device cannot determine the target microservice according to the primary access address in the HTTP resource access request. The internet connection device can judge whether the primary access address can be used for directly determining the target micro service, if so, the step S21 can be executed to obtain the webpage resource and send the webpage resource to the client side, so that the webpage resource can be loaded; if not, the following step S22 may be executed to implement the loading of the web page resource.
S21: and directly sending the HTTP resource access request to the target micro service to obtain the webpage resource and sending the webpage resource to the client so as to load the webpage resource.
Specifically, if the target web resource requested to be accessed by the HTTP resource access request is a top-level web resource of the browser page (e.g., an HTML file of H5 page), since the primary access address in the HTTP resource access request can be directly used to determine the target micro-service, the inter-network connection device can directly determine the target micro-service according to the primary access address in the HTTP resource access request, and thus directly forward the HTTP resource access request to a node corresponding to the target micro-service, so as to obtain the target web resource.
For example, the resource file of the HTTP resource access request is a first-level web page resource, such as an HTML file, the primary access address of the HTML file is HTTP:// www.xxxx.com/userinfo/a. HTML, the internetwork connecting device obtains path information userinfo from the primary access address, determines to obtain a corresponding target micro-service by using the path information userinfo, and further forwards the HTTP resource access request to one of nodes corresponding to the target micro-service by using a global load balancing strategy to obtain the HTML file.
Optionally, after receiving the target web page resource fed back by the node, establishing association between path information corresponding to the target web page resource and the target micro-service.
For example, the target web page resource obtained by executing step S21 is a top level web page resource in the browser web page. After receiving the first-level webpage resource fed back by the node of the target micro service, the internetwork connecting device forwards the first-level webpage resource to the client, and the client loads the first-level webpage resource to a browser page currently visited by a user, so that the loading of the first-level webpage resource is realized; in addition, because the resources of the same browser page are generally stored in the same micro-service, at this time, the internetworking connection device determines that the target micro-service can obtain the resources of the browser page, so that the association between the target micro-service and the path information of the first-level web resource is established. Therefore, the access of the non-first-level webpage resources of the page can be realized by establishing the association relationship between the path information of the first-level webpage resources of the page and the related micro-services.
S22: and acquiring the header information in the HTTP resource access request.
In this embodiment, for the description of this step, reference may be made to the description of the corresponding location in an embodiment of the resource access method of the present application, and details are not described here.
S23: and judging whether the target webpage resource type is a preset resource type according to the HTTP resource access request.
If not, go to step S24.
If the resource type is the preset resource type, step S25 is executed.
The preset resource type is a type capable of continuously loading the lower-level webpage resources. Alternatively, the preset webpage resource type may be HTML, CSS, JS, pictures, fonts, and the like.
Optionally, the header information may further include header Accept information. Specifically, header Accept information in the header information may be obtained, and it is determined whether the header Accept information includes a preset character string; wherein, if the resource type is contained, the resource type is a preset resource type.
For example, the types capable of continuing to load the subordinate web page resource may be a CSS file and a JS file. Determining whether the target webpage resource type is the preset resource type according to the HTTP resource access request, specifically, acquiring header Accept information in the HTTP resource access request, and determining whether the header Accept information contains a CSS character string or a JS character string. And if the target webpage resource type contains the CSS character string or the JS character string, determining that the target webpage resource type is the preset resource type. Wherein, the header Accept information represents the type of data that the client (sending end) wishes to receive.
S24: and directly searching the matched target micro-service according to the header information.
In this embodiment, for a target web resource that cannot continuously load a lower level web resource, a subsequent client does not continuously send an HTTP resource access request to obtain the lower level web resource, so that a resource access address in the target web resource does not need to be updated, and a target micro service can be directly determined according to the header Referer information.
Specifically, path information for indicating a superior web resource may be acquired according to the header information; and searching the matched target micro service according to the path information.
In some embodiments, the internet connection device obtains path information corresponding to a higher-level web resource (e.g., a first-level web resource) of the target web resource from the head Referer information, and finds the target microservice associated with the path information.
S25: a secondary access address is generated from the header information.
Specifically, path information for indicating superior web page resources is acquired according to the header information; a secondary access address is generated from the path information and the primary access address contained in the HTTP resource access request.
In this embodiment, considering that for a preset resource type capable of continuously loading a lower level web resource, a subsequent client may continuously send an HTTP resource access request to obtain a next level web resource, so that the inter-network connection device can determine to obtain a target micro-service according to header refer information in the HTTP resource access request corresponding to the next level web resource, and can regenerate a secondary access address for the preset resource type and perform relocation of a resource azimuth address of the preset resource type to the client.
In an embodiment, when the internet connection device determines that the target web resource type is the preset resource type, the internet connection device obtains path information corresponding to a higher-level web resource of the target web resource from the head Referer information, and generates a secondary access address based on the primary access address and the path information. The primary access address and path information are included in generating the secondary access address.
Acquiring path information for indicating a superior web resource according to the header information, and in some embodiments, acquiring a route from a routing table according to the header information; and acquiring a prefix character string from the regular route expression of the route as path information representing a route path.
In other embodiments, a preset routing regular expression may be used to remove wildcard content belonging to the preset routing regular expression in the header Referer information, so as to obtain path information corresponding to a higher-level web resource of the target web resource.
For example, from header Referer information http:// www.xxxx.com/userinfo/a. HTML, the path information userinfo corresponding to the HTML file of the first-level web resource of the target web resource is obtained, and the secondary access address http:// www.xxxx.com/userinfo/action/b. CSS is generated based on the primary access address http:// www.xxxx.com/action/b. CSS and the path information userinfo of the CSS file. Specifically, a preset routing regular expression is used, for example, the routing regular expression is http:// www.xxxx.com// a. html, wildcard content belonging to the preset routing regular expression in the head referrer information is removed, and path information userinfo corresponding to the first-level webpage resource of the target webpage resource is obtained.
S26: and searching the matched target micro service according to the secondary access address.
Specifically, the HTTP resource access request is redirected to the secondary access address and fed back to the initiating side which initiates the HTTP resource access request; receiving an HTTP resource access request which is reinitiated by an initiating side by using a secondary access address; and searching the matched target micro service according to the secondary access address in the reinitiated HTTP resource access request.
Specifically, the internet connection device may redirect the HTTP resource access request to the secondary access address, and feed back to the client. The client resends the redirected HTTP resource access request. And the internetwork connection device receives a new HTTP resource access request reinitiated by the client by using the secondary access address, and determines the target micro service based on the secondary access address in the new HTTP resource access request.
It can be understood that, after receiving the secondary access address, the client uses the secondary access address as the resource access address of the target web resource, so that when the client requests to access the next-level web resource of the target web resource, the header refer information in the HTTP resource access request sent to the internetwork connection device includes the secondary access address of the target web resource, and compared with the original resource access address of the target web resource, the secondary access address includes the path information of the first-level web resource, so that the internetwork connection device can find the associated micro-service as the target micro-service according to the path information of the first-level web resource in the header refer information.
For example, the HTTP status code 302 is used to redirect the HTTP resource access request to the secondary access address HTTP:// www.xxxx.com/userinfo/action/b.css of the CSS file temporarily, and feed back to the client, the client receives a new HTTP resource access request reinitiated by the client using the secondary access address, and obtains the path information userinfo of the HTML file of the top-level web page resource from the secondary access address HTTP:// www.xxxx.com/userinfo/action/b.css in the new HTTP resource access request, thereby finding out the micro-service associated with the path information userinfo as the target micro-service of the CSS file. When the client continuously loads the next-level webpage resource, such as the picture, referred by the CSS file, the internetwork connecting device receives the related HTTP resource access request, determines that the target micro-service cannot be determined according to the resource access address of the picture in the HTTP resource access request, acquires header Referer information in the HTTP resource access request, namely a new resource access address HTTP:// www.xxxx.com/userinfo/action/b.css of the CSS file, acquires path information userinfo of the first-level webpage resource from the HTTP resource access request, and further finds out the micro-service associated with the path information userinfo as the target micro-service of the picture.
S27: and sending the HTTP resource access request to a target micro service so as to access the target webpage resource corresponding to the HTTP resource access request.
For example, the internetworking connection device may forward the HTTP resource access request to the node corresponding to the target microservice using a load balancing policy.
After the matched target micro-service is found in step S24 or step S26, the HTTP resource access request is forwarded to the node corresponding to the target micro-service to obtain the target web page resource.
In this embodiment, for the description of this step, reference may be made to the description of the corresponding location in an embodiment of the resource access method of the present application, and details are not described here.
Further, after the step S21 or the step S27 is executed, if the target web page resource is Not obtained by the internet connection device, a prompt of resource obtaining failure may be fed back to the client, for example, 404Not Found error code is returned.
In any of the above embodiments, the internetworking connection device may be a Zuul gateway. In a specific application, the Zuul gateway includes functions such as route lookup, static resource transparent proxy, and load balancing, where the route lookup function determines a target micro-service according to a primary access address in an HTTP resource access request as described above, the static resource transparent proxy function determines a target micro-service of a non-top-level web resource through the above related steps, and the load balancing function selects a node from a plurality of nodes corresponding to the target micro-service by using a load balancing policy as described above. In addition, the Zuul gateway may be provided with a filter (also referred to as Zuul filter), which may be classified into 4 filter types of pre, route, post, error, respectively corresponding to a pre-filter, a route filter, a post-filter, and an error filter. The functions of the pre-filter, the route filter, the post-filter and the error filter can be described by referring to the filter of the prior Zuul. In addition, the pre-filter is also used for realizing the functions of the static resource transparent proxy.
Referring to fig. 3, fig. 3 is a schematic structural diagram illustrating an embodiment of an internetworking connection device according to the present application, where the internetworking connection device 300 in this embodiment includes a header acquirer 301, a route finder 302 and a request forwarder 303.
A header acquirer 301, configured to acquire header information in the HTTP resource access request.
And the route finder 302 is used for finding the matched target microservice according to the header information.
Specifically, the matched target micro-service is searched according to the header Referer information in the header information.
And the request forwarder 303 is configured to send the HTTP resource access request to the target micro service to access the target web page resource corresponding to the HTTP resource access request.
The request forwarder 303 forwards the HTTP resource access request to a node corresponding to the target microservice by using a load balancing policy.
Optionally, the route finder 302 is further configured to determine whether a matching target microservice can be found according to the primary access address in the HTTP resource access request. The route finder 302 is specifically configured to execute the step of sending the HTTP resource access request to the target micro service to access the target web resource corresponding to the HTTP resource access request when the matched target micro service can be found according to the primary access address or the matched target micro service can be found according to the header information. The route finder 302 is specifically configured to perform the step of finding the matched target micro service according to the header information when the matched target micro service cannot be found according to the primary access address.
Optionally, the head obtainer 301 is further configured to: and judging whether the target webpage resource type is a preset resource type according to the HTTP resource access request. Specifically, header Accept information in the header information may be acquired, and it may be determined whether the header Accept information contains a preset character string. Wherein, if the resource type is contained, the resource type is a preset resource type.
The address generator 303 is specifically configured to execute a step of generating a secondary access address according to the header information when the target web page resource type is a preset resource type; and/or the route finder 302 is specifically configured to, when the target web page resource type is not the preset resource type, directly find the matched target micro service according to the header information. The preset resource type may include multiple levels of static resources, and the multiple levels of static resources may be CSS files.
The step of generating the secondary access address according to the header information specifically includes: acquiring path information for indicating superior webpage resources according to the header information; a secondary access address is generated based on the path information and the primary access address contained in the header information. The gateway 300 further comprises an address generator 303. The address generator 303 is used to generate a secondary access address from the header information. The route finder 302 is specifically configured to find a matching target microservice based on the secondary access address.
The step of directly searching the matched target microservice according to the header information specifically comprises the following steps: acquiring path information for indicating superior webpage resources according to the header information; and searching the matched target micro service according to the path information.
The step of obtaining path information for indicating a superior web resource according to the header information specifically includes: acquiring a route from a routing table according to the header information; and acquiring a prefix character string from the regular route expression of the route as path information representing a route path.
The gateway 300 further comprises a redirector 304. The redirector 304 is configured to redirect the HTTP resource access request to a secondary access address, and feed back to the originating side that originated the HTTP resource access request; and receiving the HTTP resource access request which is reinitiated by the initiating side by using the secondary access address. The route finder 302 is specifically configured to find a matching target microservice according to the secondary access address in the re-initiated HTTP resource access request.
The gateway 300 may be a Zuul gateway.
In this embodiment, for the explanation of the above steps, reference may be made to the explanation of the corresponding positions in one embodiment and another embodiment of the resource access method of the present application, and details are not described here again.
It is understood that the above components in the internet connection apparatus 300 may be different devices, or may be integrated into one or more devices, and are not limited herein. In some embodiments, the internetworking device is a Zuul gateway, and the above components are used to implement the above function of the Zuul filter, for example, the header acquirer 301, the route finder 302 are used to implement the above function of the pre-type filter, the request forwarder 303 is used to implement the above function of the route filter, and the redirector 305 is used to implement the above function of the post filter.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an embodiment of the storage device 400 of the present application, where the storage device 400 stores instructions, and the instructions are executed by a processor to implement the steps of the method according to any one of the embodiments.
The storage device 400 may be a medium that can store program instructions, 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, or may be a server that stores the program instructions, and the server may send the stored program instructions to other devices for operation, or may self-operate the stored program instructions.
In the above scheme, when the internetwork connecting device cannot determine the target micro-service by using the primary access address in the HTTP resource access request, the target micro-service is determined by using the header Referer information in the HTTP resource access request to obtain the target webpage resource corresponding to the HTTP resource access request, so as to realize the access of the webpage resource, and for the multi-level webpage resource, even if the non-first-level webpage resource cannot determine the target micro-service according to the primary access address in the HTTP, the target micro-service can be determined by using the header Referer information, so as to realize the access of the non-first-level webpage resource of the multi-level webpage resource, so that the access of the different-level webpage resource in the multi-level webpage resource can be realized by using the internetwork connecting device, in addition, since the access of the webpage resource can be realized by directly using the internetwork connecting device, no other proxy server can be additionally added, the resource access system architecture can be simplified.
The following goes on to list the beneficial effects produced by the above scheme in detail:
1) according to the method and the device, the transparent proxy of the webpage static resources is directly realized by using the internetwork connecting device, so that the complexity of deployment, operation and maintenance and configuration of the transparent proxy of the webpage static resources in a resource access system architecture is greatly simplified, reverse proxy servers such as Nginx and Apache are reduced, and the processing efficiency and the stability of a calling link are improved.
2) The method skillfully utilizes a refer mechanism and a 302 redirection mechanism in the HTTP resource access request, and a mechanism that a front-end browser supports the request redirected by the 302 to utilize a new URL as a subsequent resource request, thereby changing the resource access address loaded by the webpage resource, and realizing that the resource corresponding to the resource access address can be correctly loaded without rewriting the paths in the HTML file and the CSS file in the resource access system architecture through the micro-service internetworking connecting devices such as Zuul and the like.
3) The method and the device can adapt to the current mainstream webpage static resource loading, once deployed, transparent loading of the webpage static resource can be realized without any modification, and operations such as increase, offline and change of micro-services do not need to modify any static resource agent, so that operation and maintenance management work is greatly reduced, the work efficiency is improved, and the stability of a resource access system architecture is improved.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings, or which are directly or indirectly applied to other related technical fields, are intended to be included within the scope of the present application.
Claims (16)
1. A resource access method for an internetworking apparatus, comprising:
acquiring header information in the HTTP resource access request;
acquiring header Accept information in the header information, and determining whether the header Accept information contains a preset character string;
if yes, determining that the target webpage resource type of the HTTP resource access request is a multi-level static resource, generating a secondary access address according to the header information, and searching for a matched target micro-service according to the secondary access address;
if not, determining that the target webpage resource type of the HTTP resource access request is not a multi-stage static resource, and directly searching for the matched target micro-service according to the header Referer information in the header information; the header Referer information comprises path information corresponding to a superior webpage resource of the target webpage resource;
and sending the HTTP resource access request to the target micro service so as to access the target webpage resource corresponding to the HTTP resource access request.
2. The method of claim 1, wherein:
the step of generating a secondary access address according to the header information specifically includes: acquiring path information for indicating superior webpage resources according to the header information; generating the secondary access address according to the path information and the primary access address contained in the HTTP resource access request;
the step of searching for the matched target microservice directly according to the header information specifically comprises: acquiring path information for indicating superior webpage resources according to the header information; and searching the matched target micro service according to the path information.
3. The method according to claim 2, wherein the step of obtaining the path information indicating the upper level web resource according to the header information specifically includes:
acquiring a route from a routing table according to the header information;
and acquiring a prefix character string from the regular route expression of the route as path information representing a route path.
4. The method of claim 1,
the multi-level static resource is a CSS file.
5. The method of claim 1, wherein the step of finding a matching target microservice based on the secondary access address comprises:
redirecting the HTTP resource access request to the secondary access address, and feeding back to an initiating side for initiating the HTTP resource access request;
receiving an HTTP resource access request reinitiated by the initiating side by using the secondary access address;
and searching the matched target micro service according to the secondary access address in the reinitiated HTTP resource access request.
6. The method according to claim 1, wherein the step of obtaining header information in the HTTP resource access request is preceded by the step of:
judging whether the matched target micro service can be found according to the primary access address in the HTTP resource access request;
if yes, directly executing the step of sending the HTTP resource access request to the target micro service;
and if not, executing the step of acquiring the header information in the HTTP resource access request.
7. The method of claim 1, wherein the internetworking connection device is a Zuul gateway;
the step of sending the HTTP resource access request to the target microservice includes:
and forwarding the HTTP resource access request to a node corresponding to the target micro service by using a load balancing strategy.
8. An internetworking connection, comprising:
the head acquirer is used for acquiring the head information in the HTTP resource access request, acquiring the head Accept information in the head information and determining whether the head Accept information contains a preset character string;
the address generator is used for determining that the target webpage resource type of the HTTP resource access request is a multilevel static resource, generating a secondary access address according to the header information, and searching for a matched target micro-service according to the secondary access address;
the route finder is used for finding the matched target micro-service according to the secondary access address when the target webpage resource type is a multi-stage static resource, and directly finding the matched target micro-service according to the head Referer information in the head information when the target webpage resource type is not the multi-stage static resource; the header Referer information comprises path information corresponding to a superior webpage resource of the target webpage resource;
and the request forwarder is used for sending the HTTP resource access request to the target micro service so as to access the target webpage resource corresponding to the HTTP resource access request.
9. The internet connection apparatus of claim 8, wherein:
the step of generating a secondary access address according to the header information specifically includes: acquiring path information for indicating superior webpage resources according to the header information; generating the secondary access address according to the path information and a primary access address contained in the header information;
the step of searching for the matched target microservice directly according to the header information specifically comprises: acquiring path information for indicating superior webpage resources according to the header information; and searching the matched target micro service according to the path information.
10. The internet connection apparatus according to claim 9, wherein the step of obtaining the path information indicating the upper level web resource according to the header information specifically includes:
acquiring a route from a routing table according to the header information;
and acquiring a prefix character string from the regular route expression of the route as path information representing a route path.
11. The internet connection apparatus of claim 8,
the multi-level static resource is a CSS file.
12. The internet connection device of claim 8, further comprising a redirector, the redirector being configured to redirect the HTTP resource access request to the secondary access address and feed back to an originating side that originated the HTTP resource access request; receiving an HTTP resource access request reinitiated by the initiating side by using the secondary access address;
the route finder is specifically configured to find a matched target microservice according to the secondary access address in the re-initiated HTTP resource access request.
13. The internet connection device of claim 8, wherein the route finder is further configured to determine whether a matching target microservice can be found according to the primary access address in the HTTP resource access request;
the route finder is specifically configured to execute the step of sending the HTTP resource access request to the target micro service to access the target web resource corresponding to the HTTP resource access request when the matched target micro service can be found according to the primary access address or the matched target micro service can be found according to the header information;
the route finder is specifically configured to execute the step of finding the matched target micro service according to the header information when the matched target micro service cannot be found according to the primary access address.
14. The internetworking connection of claim 8, wherein the internetworking connection is a Zuul gateway;
the step of sending the HTTP resource access request to the target microservice includes:
and forwarding the HTTP resource access request to a node corresponding to the target micro service by using a load balancing strategy.
15. A resource access system, characterized in that a plurality of microservices are provided and configured comprising an internetworking connection between devices according to any of claims 8-14.
16. A storage device having stored thereon instructions which, when executed by a processor, carry out steps comprising the method of any of claims 1 to 7.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201911294600.2A CN111478935B (en) | 2019-12-16 | 2019-12-16 | Resource access method, internetwork connecting device, system and device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201911294600.2A CN111478935B (en) | 2019-12-16 | 2019-12-16 | Resource access method, internetwork connecting device, system and device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN111478935A CN111478935A (en) | 2020-07-31 |
| CN111478935B true CN111478935B (en) | 2021-03-30 |
Family
ID=71746220
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201911294600.2A Active CN111478935B (en) | 2019-12-16 | 2019-12-16 | Resource access method, internetwork connecting device, system and device |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN111478935B (en) |
Families Citing this family (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112925998B (en) * | 2021-03-30 | 2023-07-25 | 北京奇艺世纪科技有限公司 | Interface data processing method, device and system, electronic equipment and storage medium |
| CN113315708B (en) * | 2021-07-29 | 2021-10-08 | 数字广东网络建设有限公司 | System, method, computer equipment and storage medium for realizing grid gateway |
| CN113726897B (en) * | 2021-09-01 | 2024-04-19 | 马上消费金融股份有限公司 | Data processing method, device and equipment |
| CN113992738A (en) * | 2021-09-02 | 2022-01-28 | 深圳市高腾科技服务有限公司 | Reverse proxy method, device, equipment and storage medium based on micro service gateway |
| CN113791805B (en) * | 2021-09-17 | 2022-08-12 | 马上消费金融股份有限公司 | Micro-service gray level publishing method and device |
| CN114510672B (en) * | 2022-02-17 | 2025-04-15 | 上海阅维科技股份有限公司 | Internet page restoration method, system, access method, system, medium and terminal |
| CN115883530B (en) * | 2022-11-28 | 2025-10-28 | 北京锐安科技有限公司 | Page processing method and device |
| CN116527658B (en) * | 2023-05-18 | 2025-11-25 | 北京字跳网络技术有限公司 | Resource loading methods, apparatus, media and electronic equipment |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108234653A (en) * | 2018-01-03 | 2018-06-29 | 马上消费金融股份有限公司 | Method and device for processing service request |
| CN108848092A (en) * | 2018-06-20 | 2018-11-20 | 中国联合网络通信集团有限公司 | The processing method and processing device of micro services gray scale publication based on call chain |
| CN109067914A (en) * | 2018-09-20 | 2018-12-21 | 星环信息科技(上海)有限公司 | Proxy Method, device, equipment and the storage medium of Web service |
| CN110519379A (en) * | 2019-08-29 | 2019-11-29 | 泰康保险集团股份有限公司 | Request processing method and equipment based on micro services |
| US10574736B2 (en) * | 2017-01-09 | 2020-02-25 | International Business Machines Corporation | Local microservice development for remote deployment |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108306877B (en) * | 2018-01-30 | 2020-11-10 | 泰康保险集团股份有限公司 | NODE JS-based user identity information verification method and device and storage medium |
-
2019
- 2019-12-16 CN CN201911294600.2A patent/CN111478935B/en active Active
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US10574736B2 (en) * | 2017-01-09 | 2020-02-25 | International Business Machines Corporation | Local microservice development for remote deployment |
| CN108234653A (en) * | 2018-01-03 | 2018-06-29 | 马上消费金融股份有限公司 | Method and device for processing service request |
| CN108848092A (en) * | 2018-06-20 | 2018-11-20 | 中国联合网络通信集团有限公司 | The processing method and processing device of micro services gray scale publication based on call chain |
| CN109067914A (en) * | 2018-09-20 | 2018-12-21 | 星环信息科技(上海)有限公司 | Proxy Method, device, equipment and the storage medium of Web service |
| CN110519379A (en) * | 2019-08-29 | 2019-11-29 | 泰康保险集团股份有限公司 | Request processing method and equipment based on micro services |
Also Published As
| Publication number | Publication date |
|---|---|
| CN111478935A (en) | 2020-07-31 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN111478935B (en) | Resource access method, internetwork connecting device, system and device | |
| US10791201B2 (en) | Server initiated multipath content delivery | |
| US8706906B2 (en) | Multipath routing process | |
| CN106489145B (en) | Access method, device and the Web site system of web site | |
| US8321503B2 (en) | Context-specific network resource addressing model for distributed services | |
| JP5893034B2 (en) | Request routing in network environments | |
| US9160703B2 (en) | Request routing management based on network components | |
| US9871850B1 (en) | Enhanced browsing using CDN routing capabilities | |
| US8577992B1 (en) | Request routing management based on network components | |
| US8660976B2 (en) | Web content rewriting, including responses | |
| US7640296B2 (en) | Mapping of a content request for a cache server | |
| US8326956B2 (en) | System and method for handling persistence information in a network | |
| US20100049842A1 (en) | Computing Environment Arranged to Support Predetermined URL Patterns | |
| US20150248455A1 (en) | Content name resolution for information centric networking | |
| CN108353095A (en) | Domain name resolution method, client, edge node and domain name resolution system | |
| US10148735B1 (en) | Application layer load balancer | |
| CN104104649A (en) | Webpage logging method, device and system | |
| KR20140021602A (en) | Global traffic management using modified hostname | |
| CN110674427B (en) | Method, device, equipment and storage medium for responding to webpage access request | |
| CN112583863B (en) | HttpDNS scheduling method, device, medium and equipment | |
| JP7821218B2 (en) | NETWORK NODE AND METHOD IN A NETWORK NODE FOR INDIRECT COMMUNICATION - Patent application | |
| WO2017166524A1 (en) | Domain name parsing method and apparatus | |
| CN117938807B (en) | Method, device and system for carrying out portrayal on local DNS (Domain name System) for CDN (content delivery network) | |
| CN110392069A (en) | CDN traffic scheduling processing method and CDN server | |
| US10455039B2 (en) | Method and router for sending and processing data |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |