A solution to the problem of nginx caching a page back string session

  • 2020-05-10 23:10:21
  • OfStack

nginx supports page caching. I introduced the configuration scheme on my blog before. Yesterday, there was a weird problem. After someone else's machine logs in, the user information of someone else will appear on the homepage of my machine.

After checking, nginx will cache the header information of the response page, including Set-cookie, causing the user's cookie of the subsequent page to be set as the header of the cache.
Solution, nginx provides the proxy_hide_header directive to remove the relevant response header information:

proxy_hide_header Set-Cookie;

Conclusion: after configuration, the problem of string sessions no longer occurs

Related articles: