Welcome! Log In Create A New Profile

Advanced

WordPress: Need help with cookie checking directive for Cookies For Comments plugin

Posted by GerryBot 
WordPress: Need help with cookie checking directive for Cookies For Comments plugin
January 14, 2013 04:34PM
I need some help writing an Nginx rule for the WordPress Cookies For Comments plugin. There's an Apache .htaccess rule that seems to block most spam simply by checking for the presence of a cookie before allowing access to the wp-comments-post.php file. If the cookie doesn't exist, you get a 403 error.

The Apache version of the rules is (where "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" is the cookie string):

RewriteCond %{HTTP_COOKIE} !^.*xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.*$
RewriteRule ^wp-comments-post.php - [F,L]

Is there a way to convert this so that it works for Nginx? I've tried a location-based rule, but it doesn't quite work. Any Nginx veterans have suggestions for how to make this work? Here's what I've been trying to work with:

location ~* wp-comments-post.php {
if ($http_cookie !~* "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") {
return 403;
break;
}
}
Re: WordPress: Need help with cookie checking directive for Cookies For Comments plugin
February 01, 2013 05:18PM
maybe this will help
http://stackoverflow.com/questions/3542149/check-the-existence-of-a-session-nginx

http://xDNS.ro && http://xLiST.ro Powered By nginX
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 129
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready