samedi 16 juillet 2016

Nginx $http_cookie if directive pattern matching

So on the Nginx documentation it is a bit unclear but it appears we can use Regex to match anything within the if statement

http://ift.tt/29zuz9T

So i wanted to tweak this to make it so Nginx checks the value of any cookie.

But my following string what should be from my understanding * matching any cookie name and = matching any cookie contents.

if ($http_cookie ~* "*=*") {
return 444;
}

But i get the error "pcre_compile() failed: nothing to repeat in "" at "" in"

What i am trying to achieve is to Have nginx check the cookie like a WAF (web application firewall) to make sure it only contains A-Z uppercase a-z lowercase 0-9 + - _ . my PHP app is Joomla what does these checks too but be useful if i could perform these checks with Nginx too since it could deny the request faster.

Aucun commentaire:

Enregistrer un commentaire