Session keeping method and system based on Nginx and Lua and storage medium
By using Lua scripts in Nginx to determine the session holding policy and forward the request, the session loss and load uneven problems of the session holding policy in Nginx are solved, and the effects of stable session holding and load balancing are achieved.
Patent Information
- Application Number
- CN202510136174.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-07
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2045-02-07
AI Technical Summary
The commonly used session retention strategies in existing Nginx have problems with session loss risk and load imbalance.
By combining Nginx and Lua technologies, client request information is obtained, request information is parsed and request paths are matched, Lua script is called to determine the session retention policy, and forward the request to the specified backend server according to the upstream block information specified in the Nginx configuration file.
It realizes that the same user request on the client is always routed to the same backend server, ensuring the stability of the session and optimizing system performance through load balancing.
Smart Images

Figure CN119629182A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of software development, and in particular to a session maintenance method, system and storage medium based on Nginx and Lua. Background Art
[0002] Session persistence technology is crucial in Web applications. It ensures that users can continue to access the same backend service in multiple requests, thereby maintaining the state and data consistency of the user session. This is essential for providing a smooth user experience, enhancing data security, and improving application performance.
[0003] In Nginx, there are three common session retention strategies: ip_hash, url_hash, and sticky_cookie_insert. These strategies enable Nginx to effectively maintain user sessions and improve the overall performance of the application and user experience. However, these strategies also have their own disadvantages. For example, if the user changes the IP address due to network switching, the session may be lost. In addition, in a shared IP environment, this method may lead to uneven load distribution; different URL parameters may cause the session to be routed to different servers, which may cause uneven load for applications with more dynamic content; users clearing cookies or cookies expired will cause session loss. Summary of the invention
[0004] The present application provides a session maintenance method, system and storage medium based on Nginx and Lua to solve the problems of session loss risk and load imbalance in the session maintenance strategy commonly used in Nginx in the prior art.
[0005] In a first aspect, the present application provides a session persistence method based on Nginx and Lua, comprising: Get the request information initiated by the client; Parse the request information and match the corresponding request path based on the location block information in the Nginx configuration file; If the request path matches successfully, the Lua script in the location block is called and the session persistence strategy to be adopted is determined; Based on the upstream block information in the Nginx configuration file and according to the determined session persistence strategy, the request information is forwarded to the designated backend server, so that the same user request is routed to the same backend server.
[0006] Furthermore, calling the Lua script in the location block and determining the adopted session retention strategy includes: Obtaining request parameters in the request information; Determining a parameter type of the request parameter; Calling a corresponding method according to the parameter type to assign a value to a target ID variable in the Lua script; After the assignment is completed, the Lua script is run to determine the session persistence strategy to be adopted.
[0007] Further, the parameter types include an IP address, a user ID, a URL, and a message request body BODY, and the calling of a corresponding method according to the parameter type to assign a value to a target ID variable in the Lua script includes: Obtain the IP address in the request information through the ngx.var.remote_addr method, and assign the IP address to the target ID variable; Get the user ID from the request header in the request information through the ngx.req.get_headers() method, and assign the user ID to the target ID variable; Obtain the complete URI in the request information through the ngx.var.request_uri method, and assign the complete URI to the target ID variable; First, introduce the JSON library to parse the JSON data in the request body of the request information, then read the request body through the ngx.req.read_body() method, and finally obtain and parse the JSON data through the ngx.req.get_body_data() method, and assign the specified parameters to the target ID variable.
[0008] Further, the method of forwarding the request information to a designated backend server based on the upstream block information in the Nginx configuration file and according to the determined session persistence strategy, so that the same user request is routed to the same backend server, includes: Performing a hash operation based on the value assigned to the target ID variable to determine the target backend server to which the request information is forwarded; Based on the server group preset in the upstream block in the Nginx configuration file, the backend servers are load balanced using software. Based on the determined target backend server and load balancing processing, the request information is forwarded to the designated backend server through preset instructions, so that the same user request is routed to the same backend server.
[0009] Further, parsing the request information and matching the corresponding request path based on the location block information in the Nginx configuration file includes: According to the URI in the request information, the location blocks in the Nginx configuration file are traversed one by one to find matching rules to determine the request path corresponding to the URI.
[0010] Furthermore, the Lua script defines the association relationship between the cache data and the user information.
[0011] Furthermore, by customizing and adjusting the Lua script, the session persistence strategy is customized, and multiple routing strategies for routing client request information to the backend server are implemented, wherein the multiple routing strategies include at least: routing strategies based on IP address, user information, URL, Cookie and Token.
[0012] In the second aspect, the present application provides a session persistence system based on Nginx and Lua, comprising: a client module, a routing forwarding module and a back-end server module, wherein the client module is used to send a user's request message, the routing forwarding module is used to execute any of the methods described in the first aspect, and the back-end server module is used to receive the client request information routed by the routing forwarding module.
[0013] Furthermore, the routing forwarding module includes a custom configuration module, and the custom configuration module is used for the user to configure different session routing strategies.
[0014] In a third aspect, the present application also provides a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute the session persistence method based on Nginx and Lua described in the present application.
[0015] The embodiment of the present application provides a session maintenance method and system based on Nginx and Lua, which obtains the request information initiated by the client; parses the request information, and matches the corresponding request path based on the location block information in the Nginx configuration file; if the request path matches successfully, the Lua script in the location block is called and the adopted session maintenance strategy is determined; based on the upstream block information in the Nginx configuration file, and according to the determined session maintenance strategy, the request information is forwarded to the specified back-end server, so that the same user request is routed to the same back-end server. In this way, through the combination of the Nginx configuration file and the Lua script, since the processing logic defined in the location block in the Nginx configuration file is to call and execute the Lua script, and the Lua script can customize multiple routing strategies based on IP address, user information, URL, Cookie and Token, when the Lua script is called in the Nginx configuration file and the session maintenance strategy is specified, the session maintenance strategy can flexibly respond to different usage scenarios, and realize that the same user request of the client is always routed to the same back-end server (session maintenance) and load balancing. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0018] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0019] Figure 1 A flowchart of a session maintenance method based on Nginx and Lua provided in an embodiment of the present application; Figure 2 This is a detailed flow chart of step S103 in the embodiment of the present application; Figure 3 A module flow chart of a session persistence system based on Nginx and Lua provided in an embodiment of the present application. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0021] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0022] Nginx (engine x) is a high-performance HTTP and reverse proxy web server. In Nginx, there are three common session persistence strategies: ip_hash, url_hash, and sticky_cookie_insert. The specific principles are as follows: ip_hash: This mechanism routes requests to specific backend services based on the client's IP address by hashing the IP address. In this way, requests from the same IP address will always be directed to the same server.
[0023] url_hash: This strategy hashes the requested URL path to ensure that users accessing the same resource are always routed to the same server, thereby achieving session persistence.
[0024] sticky_cookie_insert: A session persistence mechanism based on cookies (data stored on the user's local terminal, also known as cached data). When a user visits for the first time, Nginx will insert a specific cookie to track the user's session. In subsequent requests, the user will carry this cookie, and Nginx will route the request to the corresponding server based on the value of the cookie.
[0025] These strategies enable Nginx to effectively maintain user sessions and improve the overall performance of the application and user experience. However, these strategies also have their own disadvantages, such as: ip_hash: This strategy is simple to use, easy to configure, and can quickly maintain sessions. However, if the user changes the IP address due to network switching, the session may be lost. In addition, in a shared IP environment, this method may lead to uneven load distribution.
[0026] url_hash: This strategy ensures the consistency of requests for the same resource, and is particularly suitable for static content or specific API access, which helps improve cache utilization. However, different URL parameters may cause sessions to be routed to different servers, which may cause uneven load for applications with more dynamic content, thus affecting overall performance.
[0027] sticky_cookie_insert: This strategy can effectively cope with changes in user IP or URL, maintain session consistency, is suitable for high availability and load balancing environments, and flexibly cope with changing request patterns. However, attention should be paid to the security of cookies. If users clear cookies or cookies expire, the session will be lost.
[0028] Based on this, in order to solve the problems in the prior art, the present application provides a session persistence method and system based on Nginx and Lua. The Nginx server can efficiently process requests and use Lua scripts for flexible request processing and parameter extraction, while ensuring load balancing and session persistence.
[0029] Figure 1 A session maintenance method based on Nginx and Lua is provided in an embodiment of the present application, and the method includes: S101, obtaining request information initiated by the client; In this application, session persistence means that the same user request from the client is always routed to the same backend server. In one embodiment, the request information initiated by the client refers to the request initiated by the user through a browser or other client (such as: mobile application, API client), specifically, these requests usually include the following parts: URL (Uniform Resource Locator, which is the uniform resource locator mark of WWW, that is, the network address): contains the requested resource location, such as: http: / / example.com / api / data.
[0030] Headers: Contains meta-information, such as request type (GET, POST, etc.), authentication information (Bearer Token, etc.), content type (Content-Type, etc.).
[0031] Body data: Some requests, especially POST requests, can contain data, usually JSON data or form data.
[0032] In the embodiment of the present application, since the request information initiated by the client needs to be always routed and forwarded to the same back-end server, the request information initiated by the client needs to be obtained first during the entire processing process.
[0033] In addition, since the present application is a session persistence method combining Nginx and Lua, it involves the deployment and implementation of the Nginx server. Specifically, in the embodiment of the present application, the deployment steps and implementation scheme of the Nginx server include the following aspects: 1. Write a Lua script: First, initialize a result_id variable (target ID variable) with an initial value of null. Then define a Lua script through rewrite_by_Lua to process client requests and assign a value to result_id. Specifically, if the request parameter in the client request is an IP address, the client IP is obtained through the ngx.var.remote_addr method, and result_id is set to the client IP; if the request parameter in the client request is USER, the user ID in the header is obtained through the ngx.req.get_headers() method, and result_id is set to the user ID; if the request parameter in the client request is a URL, the client's request URI is obtained through the ngx.var.request_uri method, and result_id is set to the URI; if the request parameter in the client request is a specified parameter in the body, first introduce the JSON library through local json=require("cjson.safe") to parse the JSON data in the request body, then read the request body through the ngx.req.read_body() method, and finally parse the JSON data through ngx.var.result_id=json.decode(ngx.req.get_body_data()).xxx, and set the target value xxx to the result_id variable.
[0034] 2. Write the Nginx configuration file: First, define the basic configuration worker_processes and error_log logs / error.log debug, where worker_processes defines the number of worker threads, and error_log logs / error.log debug specifies the file path and log level of the error log. Then define the time module configuration events and worker_connections, and set the maximum number of connections for each worker process; then define the HTTP configuration block, upstream defines an upstream server group for load balancing, configures all server addresses, and hash $result_id indicates that the result_id variable obtained by the Lua script is used for hash calculation and the server for routing is selected. The same result_id will be routed to the same server, thereby achieving session persistence. Then define the server configuration and request processing logic. Specifically, listen defines the Nginx listening port, server_name defines the server name, location defines matching a specific request path, calls the Lua script and specifies the session persistence strategy, and proxy_pass forwards the request to the upstream server group to complete the hash calculation and select the route.
[0035] 3. Start the Nginx service: Specifically, use the sudo systemctl start nginx command to start the Nginx service.
[0036] It should be noted that the Nginx and Lua-based session persistence method provided in the embodiment of the present application is implemented based on the written Lua scripts and Nginx configuration files.
[0037] S102, parsing the request information, and matching the corresponding request path based on the location block information in the Nginx configuration file; In an embodiment of the present application, when the client's request information reaches the Nginx server, Nginx, as a reverse proxy server, first parses the request information, specifically including: parsing HTTP methods, such as GET, POST, PUT, DELETE, etc.; parsing URI (Uniform Resource Identifier in the request message): the Nginx server matches the configuration based on this information; parsing Headers: extracting request header information, which can be used for subsequent processing; parsing Body: if there is Body data, the Nginx server will also read this part for use in subsequent processing logic.
[0038] Since the location block in Nginx is an important configuration unit, it is used to match and process client requests according to the requested URI (Uniform Resource Identifier). The location block can be nested in the server block or in other location blocks to implement complex request processing logic. Furthermore, the location block defines a location matching rule in the Nginx configuration file. When the client sends a request, Nginx matches the location block according to the requested URI and executes the corresponding processing instructions. The location block can not only match specific paths, but also perform more complex matching through regular expressions. Therefore, in an embodiment of the present application, after parsing the request information, according to the URI in the request information, the location blocks in the Nginx configuration file are traversed one by one to find the most matching rules to determine the request path corresponding to this URI. For example, if the URI in the request information is " / api / data", and there is location / api{...} in the configuration file, then this request information will match this block.
[0039] Furthermore, once a matching location block is found, the Nginx server will execute the processing logic defined in the block, such as forwarding requests, executing Lua scripts, etc.
[0040] S103, if the request path matches successfully, calling the Lua script in the location block and determining the session retention strategy to be adopted; In the embodiment of the present application, users can customize session persistence strategies and implement multiple routing strategies based on IP address, user information, URL, Cookie and Token by adjusting Lua scripts to flexibly respond to different usage scenarios. In addition, Lua scripts also define the association between cache data (Cookie) and user information, enhance the security of Cookie, and avoid the risk of session loss caused by user clearing Cookie or Cookie expiration.
[0041] For further information, see Figure 2 , step S103 includes the following sub-steps: S1031, obtaining request parameters in the request information; S1032. Determine the parameter type of the request parameter; S1033, calling a corresponding method according to the parameter type to assign a value to a target ID variable in the Lua script; S1034: After the assignment is completed, the Lua script is run to determine the adopted session retention strategy.
[0042] In one embodiment, the parameter types include IP address, user ID, URL and message request body BODY. Specifically, according to different parameter types, this application includes the following function call methods for assigning values to the target ID variable (i.e., detailed implementation methods of step S1033): The first method (parameter type is IP address): obtain the IP address in the request information through the ngx.var.remote_addr method, and assign the IP address to the target ID variable (result_id variable). This method can be used to identify users or perform access control. The second type (parameter type is user ID): Get the user ID (if any) from the request header in the request information through the ngx.req.get_headers()["User-ID"] method, and assign the user ID to the target ID variable. This method is usually used for authentication or personalized services. The third method (parameter type is URL): Get the full URI in the request information through the ngx.var.request_uri method, and assign this full URI to the target ID variable. This method is suitable for some routing or logging scenarios; The fourth type (parameter type is message request body BODY): first introduce the JSON library to parse the JSON data in the request body of the request information, then read the request body through the ngx.req.read_body() method, and finally obtain and parse the JSON data through the ngx.req.get_body_data() method, and assign the specified parameter (such as username) to the target ID variable.
[0043] After the above-mentioned assignment of the target ID variable, the Lua script is run to determine the session persistence strategy to be adopted. It should be noted that the session persistence strategy in this application is a variety of routing strategies, rather than a routing strategy based on a single parameter type. For example, it can be a session persistence strategy based on the client IP address, a session persistence strategy based on the client user information, a session persistence strategy based on the URL in the client request information, a session persistence strategy based on the client Cookie, or a session persistence strategy based on the client Token. In a specific application scenario, in order to ensure the correctness and continuity of session maintenance, it can be a fusion strategy based on session persistence strategies of multiple parameter types.
[0044] S104: Based on the upstream block information in the Nginx configuration file and according to the determined session persistence policy, the request information is forwarded to a designated backend server, so that the same user request is routed to the same backend server.
[0045] In the embodiment of the present application, after processing the request information of the client and forwarding the request information to the designated back-end server, it is necessary to consider the load balancing of the back-end server to avoid communication problems caused by overloading of the back-end server. Specifically, since the upstream block in the Nginx configuration file defines an upstream server group for load balancing and configures all server addresses, in one embodiment, based on the server group preset in the upstream block in the Nginx configuration file, polling, IP hashing, etc. are used to load balance the back-end servers. In addition, in order to ensure that routing forwarding is completed based on the adopted session retention strategy, it is necessary to perform a hash operation on the assignment of the target ID variable to determine the target back-end server to which the request information is forwarded, and in the location block, the request information is forwarded to the designated back-end server (target back-end server) through the proxy_pass instruction, so that the same user request is routed to the same back-end server.
[0046] In the embodiment of the present application, through the combination of Nginx configuration file and Lua script, since the processing logic defined in the location block in the Nginx configuration file is to call and execute the Lua script, and the Lua script can customize multiple routing strategies based on IP address, user information, URL, Cookie and Token, when the Lua script is called in the Nginx configuration file and the session retention strategy is specified, the session retention strategy can flexibly respond to different usage scenarios, including: 1. When users switch network IP or are in a shared IP environment, they may face the problem of session loss and uneven load. Through the Lua script, intelligent routing can be performed according to user identity information to ensure the stability of the session; 2. Through the Lua script (based on the server group preset in the upstream block in the Nginx configuration file, the back-end server is load balanced by polling, IP hashing, etc.), the load strategy can be adjusted in real time, resource allocation can be optimized, and the overall performance of a session retention system based on Nginx and Lua provided by the present application can be improved; 3. When the URL parameters in the request information change, the same user's request may be dispersed to different back-end servers. The Lua script can standardize the request path (the location definition matches a specific request path) and maintain the consistency of the session. In addition, for applications with more dynamic content, traditional strategies may cause uneven load, while the flexibility of Lua scripts allows real-time load adjustment to optimize performance; 4. When the user clears cookies or the cookies expire, causing session loss, since Lua scripts record the association between cookies and user information, the security of cookies can be enhanced with the help of Lua scripts. Furthermore, an effective session recovery mechanism can be designed to prevent session anomalies caused by cookie tampering, reduce the risk of session loss, and thus improve the stability and reliability of the system of this application. In summary, this application implements the routing and forwarding of the same user request from the client to the same backend server (session persistence) and load balancing.
[0047] like Figure 3 As shown, an embodiment of the present application provides a session maintenance system based on Nginx and Lua, which includes a client module, a routing forwarding module and a back-end server module, wherein the client module is used to send a user's request message, the routing forwarding module is used to execute the technical processing steps in any of the aforementioned method embodiments of the present application, and the back-end server module is used to receive the client request information routed by the routing forwarding module.
[0048] In addition, the routing forwarding module also includes a custom configuration module, and the custom configuration module is used for users to configure different session routing strategies.
[0049] A session persistence system based on Nginx and Lua in an embodiment of the present application can be composed of multiple software modules, and the technical features provided by any of the aforementioned method embodiments are loaded to achieve always routing and forwarding the same user request of the client to the same back-end server (session persistence) and load balancing.
[0050] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the session persistence method based on Nginx and Lua provided in any of the aforementioned method embodiments are implemented.
[0051] The device / system embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place or distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0052] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution, in essence, or the part that contributes to the relevant technology, can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.
[0053] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0054] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A session maintenance method based on Nginx and Lua, characterized in that: The method comprises: Get the request information initiated by the client; Parse the request information and match the corresponding request path based on the location block information in the Nginx configuration file; If the request path matches successfully, the Lua script in the location block is called and the session persistence strategy to be adopted is determined; Based on the upstream block information in the Nginx configuration file and according to the determined session persistence strategy, the request information is forwarded to the designated backend server, so that the same user request is routed to the same backend server.
2. The method according to claim 1, characterized in that The calling of the Lua script in the location block and determining the adopted session retention strategy includes: Obtaining request parameters in the request information; Determining a parameter type of the request parameter; Calling a corresponding method according to the parameter type to assign a value to a target ID variable in the Lua script; After the assignment is completed, the Lua script is run to determine the session persistence strategy to be adopted.
3. The method according to claim 2, characterized in that The parameter types include an IP address, a user ID, a URL, and a message request body BODY, and the calling of a corresponding method according to the parameter type to assign a value to a target ID variable in the Lua script includes: Obtain the IP address in the request information through the ngx.var.remote_addr method, and assign the IP address to the target ID variable; Get the user ID from the request header in the request information through the ngx.req.get_headers() method, and assign the user ID to the target ID variable; Obtain the complete URI in the request information through the ngx.var.request_uri method, and assign the complete URI to the target ID variable; First, introduce the JSON library to parse the JSON data in the request body of the request information, then read the request body through the ngx.req.read_body() method, and finally obtain and parse the JSON data through the ngx.req.get_body_data() method, and assign the specified parameters to the target ID variable.
4. The method according to claim 2 or 3, characterized in that: The method of forwarding the request information to a designated backend server based on the upstream block information in the Nginx configuration file and according to the determined session persistence strategy, so that the same user request is routed to the same backend server, includes: Performing a hash operation based on the value assigned to the target ID variable to determine the target backend server to which the request information is forwarded; Based on the server group preset in the upstream block in the Nginx configuration file, the backend servers are load balanced using software. Based on the determined target backend server and load balancing processing, the request information is forwarded to the designated backend server through preset instructions, so that the same user request is routed to the same backend server.
5. The method according to claim 1, characterized in that The parsing of the request information and matching the corresponding request path based on the location block information in the Nginx configuration file includes: According to the URI in the request information, the location blocks in the Nginx configuration file are traversed one by one to find matching rules to determine the request path corresponding to the URI.
6. The method according to claim 1, characterized in that The Lua script defines the association relationship between cache data and user information.
7. The method according to claim 1, characterized in that By customizing and adjusting the Lua script, the session persistence strategy is customized, and multiple routing strategies for routing client request information to the backend server are implemented, wherein the multiple routing strategies include at least: routing strategies based on IP address, user information, URL, Cookie and Token.
8. A session persistence system based on Nginx and Lua, characterized in that: The session maintenance system includes a client module, a routing forwarding module and a back-end server module, wherein the client module is used to send a user's request message, the routing forwarding module is used to execute the method described in any one of claims 1-7, and the back-end server module is used to receive the client request information routed by the routing forwarding module.
9. The system according to claim 8, characterized in that The routing forwarding module includes a custom configuration module, and the custom configuration module is used for users to configure different session routing strategies.
10. A storage medium, characterized in that: Computer executable instructions are stored, and the computer executable instructions are used to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Session holding method and system, and a load balancing device
CN107360251A
Server based on reverse proxy architecture and GIS service access control method
CN111371809A
Webpage access request processing method and device, storage medium and electronic equipment
CN117714155A
Management of multiple user sessions and user requests for multiple electronic devices
US7873734B1
Cited By
Session holding method and session holding platform
CN120528923A
Grayscale routing method and system based on IP network segment and URL subpath routing strategy
CN121396888A