我正在构建一个应用程序,需要对 api-数据组合使用情况进行一些分析。下面是我的 nginx 配置 -
location /r/ {
rewrite /r/(.*)$ http://localhost:3000/sample/route1/$1 redirect;
post_action /aftersampleroute1/$1;
}
location /aftersampleroute1/ {
rewrite /aftersampleroute1/(.*) /stats/$1;
proxy_pass http://127.0.0.1:3000;
}
Run Code Online (Sandbox Code Playgroud)
location/r/用于将浏览器请求重定向http://localhost:80/r/quwjDP4us到 api /sample/route1/quwjDP4us,该 api 使用 idquwjDP4us执行某些操作。现在在后台我想将 id 传递quwjDP4us给统计 api/stats/quwjDP4us,该 api 会更新该 id 的数据库记录。
当我启动 nginx 并发出请求时,http://localhost:80/r/quwjDP4usnginx 成功将我的请求重定向到我的应用程序,但不会在后台向 stats api 发出第二个请求。我缺少什么?
注意 -post_action不包含在 nginx 文档中,是否有我可以使用的备用模块/指令?