'Nginx Allow POST from certain countries
I am trying to restrict access to create content from certain countries only. I have tried the following nginx code
set $country_code 0;
set $country_post 0;
location / {
if ($allowed_country = no) {
set $country_code 1;
}
if ($request_method = POST) {
set $country_post 1$country_code;
}
if ($country_post = 11) {
return 444;
}
try_files $uri /index.php?$query_string;
}
The above code blocks access to the website from all ips.
I could restrict access to the website by country but not able to allow users from everywhere to access the website but only users from certain country to post content.
works
location / {
if ($allowed_country = no) {
return 444;
}
try_files $uri /index.php?$query_string;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
