I have an Nginx config with the redirect to holding pages:
location / {
...
if ($setholdingpage = 'True') {
rewrite (^.*$) /holding-page last;
}
proxy_pass $backend;
}
Also, I have a list of IPs that should be whitelisted and not redirected to holding pages. How it’s possible to do?
2
Answers
You can make use of the
allow
deny
directives.If I get you correct the whitelist will be your
$setholdingpage
variable in some sort?try this
This will send the non-whitelisted IPs to the error-page you specified. The error_page can be in the
location
as well.Not tested but this should do the trick.
References:
http://nginx.org/en/docs/http/ngx_http_access_module.html#allow
You can use the Nginx geo module to create a variable based upon client IP address, you can specify individual IP addresses or CIDR ranges:
Then override your variable if the IP matches one in your list:
I use a similar setup to block certain geographic regions but still allow Google crawlers to access my site.