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
Detailed example of clearing tablespace fragmenta...
background On mobile devices, caching between pag...
Use native JS to write a nine-square grid to achi...
1. Introduction I wrote an article before: The pr...
I started using Linux for development and enterta...
Table of contents Common version introduction Com...
background Today, while cooperating with other pr...
1. Inline style, placed in <body></body&g...
How to uninstall MySQL database under Linux? The ...
MySQL database crashes after entering password an...
The overall architecture of NGINX is characterize...
The preparation for the final exams in the past h...
This article shares the specific code of jQuery t...
Preface Every time I use the terminal to create a...
This script can satisfy the operations of startin...