【发布时间】:2020-10-03 14:32:01
【问题描述】:
这让我发疯了,希望有人能提供帮助。我有以下警告:But the 403 page is not friendly to blocked countries,我想将被阻止的人重定向到自定义 403 页面。
map $geoip2_data_country_code $allowed_country {
default no;
AU yes;
CA yes;
GB yes;
NZ yes;
US yes;
}
server {
location / {
if ($allowed_country = no) {
return 403;
}
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
}
}
我的自定义文件位于/var/www/sitename/403/index.html。我尝试了很多建议,但没有奏效:(
【问题讨论】:
-
这个
$allowed_country = no不应该是$allowed_country == no吗? -
@GeorgeUdosen 不,NGINX 配置的比较是
=(单等号)。它不是一种编程语言 :-)
标签: nginx redirect http-status-code-403 geoip2