How to check Cookie header line and custom cache on Nginx
Posted
by
user124249
on Server Fault
See other posts from Server Fault
or by user124249
Published on 2012-06-11T08:54:36Z
Indexed on
2012/06/11
10:41 UTC
Read the original article
Hit count: 185
nginx
I am trying cache for my website use Nginx Proxy module and has following requirements:
If request has cookie (in request header)
- The response will use cache of Nginx
- Hide Set-Cookie header line
If request has no cookie (in request header)
- Foward request to backend
- Don't hide h Set-Cookie header line
I use If (of rewrite module) and any directive:
if (!-e $http_cookie)
{
set $not_cache_rq 0;
set $not_cache_rp 0;
}
if ($http_cookie) {
set $not_cache_rq 1;
set $not_cache_rp 1;
}
proxy_cache_bypass $not_cache_rq;
proxy_no_cache $not_cache_rp;
proxy_hide_header Set-Cookie;
I do not know how to call cookie proxy_hide_header option when has cookie and no cookie on header line.
Please help me. Many thanks.
© Server Fault or respective owner