求大佬 nginx 跳转规则

VPS讨论 admin 3年前 (2020-05-28) 34次浏览 0个评论

thinkphp5固定原有自带规则
location / {

    if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php?s=/$1 last;
       break;
   }
}

现在想实现 IP白名单

但接口是 开放给全部人的 按道理应该很简单

location /api
{

allow all;

}

但是/api 非实际文件或目录 ,会跳转到/index.php?s=api  

按照上面的规则配置的日志
2019/05/10 13:11:50 [error] 23747#0: *11173 open() "/home/wwwroot/.com/public/api" failed (2: No such file or directory), client: 149.129.0.205, server: .com, request: "GET /api HTTP/2.0", host: ".com"

按照下面的规则配置的日志
        location  /api
        {

        allow all;
        rewrite ^(.*)$ /index.php?s=/$1 last;

        }

2019/05/10 13:13:04 [notice] 23765#0: *11175 "^(.*)$" matches "/api", client: 149.129.0.205, server: ..com, request: "GET /api HTTP/2.0", host: "..com"
2019/05/10 13:13:04 [notice] 23765#0: *11175 rewritten data: "/index.php", args: "s=//api", client: 149.129.0.205, server: ..com, request: "GET /api HTTP/2.0", host: "..com"
2019/05/10 13:13:04 [error] 23765#0: *11175 acce forbidden by rule, client: 149.129.0.205, server: ..com, request: "GET /api HTTP/2.0", host: "..com"

求大佬赐一条规则 ,请大佬喝个可乐  


免费部落 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:求大佬 nginx 跳转规则
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址