I am building an application where I need to do some analytics on the api-data combination usage. Below is my nginx configuration -
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;
}
location /r/
is used to redirect the browser request http://localhost:80/r/quwjDP4us
to api /sample/route1/quwjDP4us
which uses the id quwjDP4us
to do something.
Now in the background I want to pass the id quwjDP4us
to an stats api /stats/quwjDP4us
which updates the db record for that id.
When I start nginx and make the request http://localhost:80/r/quwjDP4us
nginx successfully redirects my request to my application but doesn't make the 2nd request in the background to the stats api. What am I missing?
Note - post_action
is not included in nginx docs, is there an alternate module/directive I can use?