today, nginx proxy manager when testing the test environment to find that there is a session page in any case can not go, after debugging found that Jsessionid's path and my access to the application of the path is not the same. I visit the application is/xxx/, and Jsessionid's path is/yyy/, this is the root of the problem! So I changed the application Sessioncookiepath, nginx reverse proxy To be blunt is to create a new context.xml file under Meta-inf under the project root path, specifically:
nginx proxy
<?xml version= "1.0" encoding= "UTF-8"?>
<context usehttponly= "true" sessioncookiepath= "/xxx/"/>
in a test environment, successfully passed, that is, as long as two path inconsistency, will reproduce the test environment problems, nginx proxy_pass with joy in the mood test environment test, the result is still not, debugging found Jsessionid path or the original/yyy/, nginx reverse proxy example incredibly did not work.
later, after thinking, modify Tomcat is not, but should modify Nginx, that is, jwilder nginx proxy through Nginx modify Jsessionid path, the experiment was successful. Here are some specific knowledge:nginx reverse proxy docker
1. If only host, port conversion, the cookie will not be lost. For example: Location/project {
Proxy_pass Http://127.0.0.1:8080/project ;
}
When http://127.0.0.1/project is accessed through a browser, there is a jsessionid in the browser's cookie. When accessed again, the browser sends the current cookie.
2. If the path also changes, you need to set the path conversion of the cookie, NGINX.CONF is configured as follows
Location/proxy_path {
& nbsp Proxy_pass Http://127.0.0.1:8080/project;
} When
accesses Http://127.0.0.1/proxy_path through a browser, there is no jsessionid in the browser's cookie. When you visit again, the background is certainly unable to get the cookie.
Plus path conversion: Proxy_cookie_path /project /proxy_path
You can output a project's cookie to the Proxy_path. The correct configuration is:
Location/proxy_path {
Proxy_pass http://127.0.0. 1:8080/project;
Proxy_cookie_path /project /proxy_path;
}