我想通过IP限制访问nginx中的网址,例如“/ start?do = login”。匹配的是参数“do = login”。 “开始”itselfe是好的。怎么做?
答案 0 :(得分:1)
This idea应该有效:
error_page 418 = @do_login;
location /start/ {
if ($arg_do = login) {
return 418;
}
# other directives for normal action
}
location @do_login {
allow xx.xx.xx.xx;
deny all;
# other directives for normal action
}
答案 1 :(得分:1)
解决!
起初我有“位置/开始”这个并且它起作用“开始”但是也可以有比“开始”更好的文本。每页一个。这适用于所有页面:
error_page 418 = @do_login;
location / {
recursive_error_pages on;
if ($arg_do = login) {
return 418;
}
index doku.php;
try_files $uri $uri/ @dokuwiki;
}
location @do_login {
allow x.x.x.x/29;
deny all;
index doku.php;
try_files $uri $uri/ @dokuwiki;
}
感谢大家的提示!
答案 2 :(得分:0)
尝试类似这样的例子
location /start/ {
if ($args ~ do=login) {
allow xx.xx.xx.xx;
deny all;
}
}