扩展现有的 nginx location

我在我的 nginx 配置中有一个位置,我希望客户端不要更改它。但我仍然希望他们有可能扩展子路径。

我将定义:

location /root {
   access_by_lua_block {
      var headers = {};
      require(my_script).protect(headers);
   }

   proxy_pass https://127.0.0.1;
}

为他们提供类似于这样的东西

location /root/subpath {
  access_by_lua_block {
      var headers = {}; //一些额外的标题
      require(my_script).protect(headers);
  }

  现在运行完整的位置/ root,然后将根代理传递到 127.0.0.1 / root / subpath
}
点赞