Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I block request by Cookie value in Nginx?

I want to block exact cookie value like PHPSESSID in Nginx. Does this possible? My site under DDoS but I can't block by IP due to shared addresses. Attackers use same value of Cookies so I try to block by cookie value.

Thanks

like image 638
J.Mae Avatar asked Sep 20 '25 23:09

J.Mae


1 Answers

server {
  ...

  if ($cookie_PHPSESSID = "XXXXXXXXXXXX") {
    return 403;
  }
}
like image 84
AnthumChris Avatar answered Sep 22 '25 13:09

AnthumChris