Nginx - 如何正确限制对子目录的访问?

时间:2014-11-13 08:19:39

标签: nginx

我在Nginx配置中有两个位置:

/ API / *

/ API /货币/ for_banki_ru / V1 / *

我需要关闭/ api / *的访问权限以及/ api / currency / for_banki_ru / v1 / *的所有人的开放访问权限。

现在我的配置中有

location ~* ^/api/    
    {   

      allow *************** - here IP;         
      deny all; 
***********************

并且

location ~* ^/api/currencies/for_banki_ru/v1/
    {   
      allow all; 
***************

结果/ api / - 已关闭,但/ api / currency / for_banki_ru / v1 /已关闭 - 在Nginx日志中有错误:

6760#7308: *235126 access forbidden by rule, client: **********, server: **********, request: "GET /api/currencies/for_banki_ru/v1/index.php HTTP/1.1"

如何开放访问/ api / currency / for_banki_ru / v1 / *?

1 个答案:

答案 0 :(得分:0)

通过将所需的API移动到另一个URL /目录来解决。

相关问题