Welcome! Log In Create A New Profile

Advanced

cookie and source IP logic in server block

October 14, 2013 06:16PM
Hello,

I'm trying to block certain IP ranges at my nginx server, but would like to offer the ability to bypass the block by completing a back-end CAPTCHA, which would set a cookie.

Currently I set the block like so:

geo $remote_addr $blocked {
default 0;
include /etc/nginx/conf/nginx-blocked-ips.conf;
}

...

recursive_error_pages on;
error_page 429 = @banned;
if ($blocked = 1) {
return 429;
}

location @banned {
set $args "";
rewrite ^ /banned/ ;
}

Since I can't nest "if" statements and I can't make a compound check using "&&" or "||" or something similar, how can I check both the blocked variable and look to see if a cookie is set?
SubjectAuthorPosted

cookie and source IP logic in server block

sfrazerOctober 14, 2013 06:16PM

Re: cookie and source IP logic in server block

Francis DalyOctober 14, 2013 06:36PM

Re: cookie and source IP logic in server block

sfrazerOctober 15, 2013 04:39PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 91
Record Number of Users: 5 on December 17, 2014
Record Number of Guests: 154 on December 17, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready