• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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