• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • Support for BIND DNS has been removed from Plesk for Windows due to security and maintenance risks.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS.

Cloudflare: blocking country with nginx

omexlu

Regular Pleskian
Hello,

I found this on the internet:
Using CloudFlare for country blocking - Nginx Library

and wondering if this can be put in the additional nginx directive on GUI that way?:
Code:
map $http_cf_ipcountry $allow {
        default yes;
        CN no;
        MX no;
        NO no;
}
if ($allow = no) {
    return 403;
}

EDIT: I have tested it in directive on GUI:
Ungültige nginx-Konfiguration: nginx: [emerg] "map" directive is not allowed here

so it don't work there where can i put them (update safe)? :) maybe /etc/nginx/conf.d/ ?

EDIT2: I think that this part can be placed (update-safe) under /etc/nginx/conf.d/:
Code:
map $http_cf_ipcountry $allow {
        default yes;
        CN no;
        MX no;
        NO no;
}

And this in additional nginx directive in GUI:
Code:
if ($allow = no) {
    return 403;
}

Right?

Thanks in advance.
 
Last edited:
Hello,

I found this on the internet:
Using CloudFlare for country blocking - Nginx Library

and wondering if this can be put in the additional nginx directive on GUI that way?:
Code:
map $http_cf_ipcountry $allow {
        default yes;
        CN no;
        MX no;
        NO no;
}
if ($allow = no) {
    return 403;
}

EDIT: I have tested it in directive on GUI:
Ungültige nginx-Konfiguration: nginx: [emerg] "map" directive is not allowed here

so it don't work there where can i put them (update safe)? :) maybe /etc/nginx/conf.d/ ?

EDIT2: I think that this part can be placed (update-safe) under /etc/nginx/conf.d/:
Code:
map $http_cf_ipcountry $allow {
        default yes;
        CN no;
        MX no;
        NO no;
}

And this in additional nginx directive in GUI:
Code:
if ($allow = no) {
    return 403;
}

Right?

Thanks in advance.


this work ?
 
Somebody know if i can do that that way.

/etc/nginx/conf.d/* :
Code:
map $http_cf_ipcountry $allow {
        default yes;
        CN no;
        MX no;
        NO no;
}

And this in additional nginx directive in GUI:
Code:
if ($allow = no) {
    return 403;
}
 
Because nobody replys on that i ask again @UFHH01 do you know if i can put that map in /etc/nginx/conf.d/ and the other part on additional nginx directive in GUI?

Because i really need that :)
 
Hi omexlu,

at this forum you will meet users with knowledge about Plesk, who might have additional knowledge here and there, but if you desire UNIQUE support, for UNIQUE cloudflare settings and/or UNIQUE nginx settings, pls. consider to ask such questions at communities, who are specialized in cloudflare knowledge and/or nginx knowledge. ;)
 
Back
Top