Please need your help. Unable to display the custom error 403 page for geoip restriction. It is always showing default error page 403 Forbidden.
Here are my Configurations.
/etc/nginx/nginx.conf
geoip2 /usr/local/GeoLite2-Country_DB_Nginx/GeoLite2-Country.mmdb {
auto_reload 60m;
$geoip2_metadata_country_build metadata build_epoch;
$geoip2_data_country_code country iso_code;
$geoip2_data_country_name country names en;
}
map $geoip2_data_country_code $allowed_country {
default no;
PK yes;
#DE yes;
#US no;
}
geo $exclusions {
default 0;
}
/etc/nginx/conf.d/www.test.com
error_page 403 /403.html;
location = /403.html {
root /var/www/html;
allow all;
internal;
}
if ($allowed_country = yes) {
set $exclusions 1;
}
if ($exclusions = "0") {
return 403;
}
I have placed the 403.html in /var/www/html and permission is 0644.
Thank you.