Hello,
Let's assume that a request has the HTTP_CF_CONNECTING_IP element in the header. This element is included by CloudFlare.
How do I block all requests that have this element in Nginx?
I've tried the following:
server {
listen 80;
listen [::]:80;
server_name _;
...
deny $http_cf_connecting_ip;
}
I figured that this way Nginx would get the IP being stored in $ http_cf_connecting_ip and block it, resolving my case. But it did not work and generated the following error:
[emerg] 402#402: invalid parameter "$http_cf_connecting_ip" in ...
I also tried the following:
server {
listen 80;
listen [::]:80;
server_name _;
...
if ($http_cf_connecting_ip) {
deny all;
}
}
And Nginx returns me another error:
[emerg] 278#278: "deny" directive is not allowed here in ...