鍍金池/ 問答/Linux/ nginx-1.13.8版的post_action是否還可用

nginx-1.13.8版的post_action是否還可用

我現(xiàn)在網(wǎng)站上提供下載文件的功能,所以想統(tǒng)計用戶是否完整下載文件,因為我前端用了nginx,通過查閱資料,我知道了nginx有post_action參數(shù),據(jù)部分文章的解讀是可以請求結(jié)束后再轉(zhuǎn)發(fā)到指定地址,我照著http://www.tipstuff.org/2012/...
這篇文章進行了嘗試,結(jié)果一直沒辦法請求到afterdownload后面指定的地址,我看了nginx日志也沒有請求,proxy_pass也是同一個服務器的地址。請問現(xiàn)在nginx這個post_action參數(shù)還可用嗎?我的代碼如下:

clipboard.png

回答
編輯回答
互擼娃

經(jīng)過我的多次試驗,最終解決了,并得出以下結(jié)論:
1.對于post_action是否還可用,答案是肯定的,但是官方文檔確實沒有看到相關說明了,但是我可以在更新的日志可以看到,它曾經(jīng)不斷更新過,并在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后面加了參數(shù),而我們設置的值一般都是域名/ip+端口這是是正常使用的,加了參數(shù)之后,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;但是,據(jù)下面一些人的評論說,不要用公共的ip,具體的原因我就不考究了,因為我的疑問已經(jīng)得到了解決。

我查閱的部分鏈接:
https://stackoverflow.com/que...
https://stackoverflow.com/que...

2018年9月20日 11:41