Home  >  Q&A  >  body text

rewrite - 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:

location =/ {
        rewrite ^/(.*) /zk/user/index.action break;
        proxy_pass http://www.sozhike.com;
                proxy_set_header        Host    $http_host; 
                proxy_set_header        X-Real-IP       $remote_addr; 
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for; 
                chunked_transfer_encoding       off; 
    }

How can I prevent a new jsessionid from being generated when using proxy_pass?

阿神阿神2688 days ago892

reply all(2)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 17:30:27

    Manage your sessions in a unified manner, for example: use a memcache to manage all sessions.

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-16 17:30:27

    Set-Cookie: This header was not passed?

    Do I need to manually pass this header to upstream through configuration?

    reply
    0
  • Cancelreply