我现在网站上提供下载文件的功能,所以想统计用户是否完整下载文件,因为我前端用了nginx,通过查阅资料,我知道了nginx有post_action参数,据部分文章的解读是可以请求结束后再转发到指定地址,我照着http://www.tipstuff.org/2012/...
这篇文章进行了尝试,结果一直没办法请求到afterdownload后面指定的地址,我看了nginx日志也没有请求,proxy_pass也是同一个服务器的地址。请问现在nginx这个post_action参数还可用吗?我的代码如下:
经过我的多次试验,最终解决了,并得出以下结论:
1.对于post_action是否还可用,答案是肯定的,但是官方文档确实没有看到相关说明了,但是我可以在更新的日志可以看到,它曾经不断更新过,并在stackoverflow找到相关语句。The post_action directive has been removed from the Nginx documentation and while it still appears to work, usage is inadvisable.
2.由于我在proxy_pass后面加了参数,而我们设置的值一般都是域名/ip+端口这是是正常使用的,加了参数之后,Then nginx will use a built-in resolver, and the "resolver" directive must be present. "resolver" is probably a misnomer; think of it as "what DNS server will the built-in resolver use". Since nginx 1.1.9 the built-in resolver will honour DNS TTL values.
我的解决方法是在@afterdownload里面,加上resolver 8.8.8.8;但是,据下面一些人的评论说,不要用公共的ip,具体的原因我就不考究了,因为我的疑问已经得到了解决。
我查阅的部分链接:
https://stackoverflow.com/que...
https://stackoverflow.com/que...