• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

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