search

Home  >  Q&A  >  body text

tomcat - session is lost when nginx uses proxy_pass reverse proxy

When configuring url rewrite in nginx, in order to keep the URL in the browser address bar unchanged, proxy_pass reverse proxy is used, but a new jsessionid will be generated every time. The specific configuration is as follows:

server {
        listen       80;
        server_name  www.demo.com;
        root /www/webapps/demo;
        index index.html index.htm;

        location / {
          proxy_pass http://localhost:81/;
          include naproxy.conf;
        }
    }

I have configured the app in tomcat as a virtual host!

According to this post, I also tried it, but it didn’t work!

What’s strange to me is that I directly use locahost:81 to access the application, and the cookie’s Path=/, which is normal!
But when you use www.demo.com to access it, the damn Path becomes abnormal!

Kneel down and wait for the master 1

滿天的星座滿天的星座2747 days ago729

reply all(1)I'll reply

  • PHPz

    PHPz2017-05-16 17:29:05

    proxy_set_header Cookie $http_cookie; 
    

    reply
    0
  • Cancelreply