A colleague asked for help: the login to the backend system was successful, but the system could not be logged in successfully, and it still jumped to the login page, but there was no problem with the same set of code in another environment. background It was learned that he used Tomcat to deploy two environments for the same project, one on the development server and one on his local computer, and the code configurations of the two environments were exactly the same. Both sides use the same nginx for reverse proxy. The nginx configuration is as follows: location /health/ { proxy_pass http://192.168.40.159:8081/health/; #No problem with the configuration} location /health-dev/ { proxy_pass http://192.168.40.202:8080/health/; #Problematic configuration} One reverse proxy to the development environment, and one reverse proxy to the local service. position Since the code configuration is exactly the same, the problem is most likely in the nginx reverse proxy. Because the location paths on both sides are different (that is, the browser paths are different), but the server paths of the reverse proxy are the same, combined with the basic principles of session, as shown in the following figure,
When nginx reverse proxy is configured in this way location /health-dev/ { proxy_pass http://192.168.40.202:8080/health/; } When the browser accesses Because the path Therefore, the next time you request the server, the browser cannot set solve nginx has a command location /health-dev/ { proxy_pass http://192.168.40.202:8080/health/; proxy_cookie_path /health /health-dev; } Restart nginx and the problem is solved. This is the end of this article about how to solve the problem of session invalidation caused by nginx reverse proxy. For more information about session invalidation caused by nginx reverse proxy, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
>>: Solutions to problems using addRoutes in Vue projects
A problem occurred when configuring a cluster. Or...
Requirement: The page needs to display an image, ...
Suppose now you want to add an item like this to ...
Business scenario requirements and implementation...
Preface My needs are syntax highlighting, functio...
Table of contents 1. Array flattening (also known...
Each of these 16 sites is worth reading carefully,...
Join query A join query refers to a matching quer...
When a running container is terminated, how can w...
centos7 switch boot kernel Note: If necessary, it...
Preface This article introduces a simple BAT scri...
Page layout has always been my concern since I st...
Preface MySQL database lock is an important means...
Strictly speaking, nginx does not have a health c...
Copy code The code is as follows: <BODY> //...