How to check the existence of a http-only secure cookie

mrtn nginx-forum at nginx.us
Wed Feb 20 22:10:26 UTC 2013


I have a http-only and secure (ssl) cookie, and I want nginx to check
whether this cookie exists in a request, if not, reject it by serving a 404
page. This is just a preliminary check, so I don't care about the actual
value in the cookie.

So far I've tried this: if ($http_cookie !~* "cookie_name=[.]+") { return
404; } in a location directive, but despite the cookie is contained in the
requests, 404 is returned. What should be corrected here? Thanks!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,236394,236394#msg-236394



More information about the nginx mailing list