Nginx post_action,proxy_pass,跟踪下载文件

我试图确定文件是否被成功下载或取消,按照这篇文章http://www.tipstuff.org/2012/08/Nginx-post-action-to-trigger-successfully-download-file.html

我做的一切都一样,但我想在同一台服务器上的proxy_pass,而不是不同的(如在这个例子是代理从nginx到Apache),它甚至有可能吗?

看着访问日志,它的行为就像没有给我任何回应,我正试图下载一个100MB的文件/file.bin,谢谢你的每一个build议!

Nginxconfiguration

server { listen 80; server_name www.somepage.com; access_log /var/log/nginx/www.somepage.com.access_log; error_log /var/log/nginx/www.somepage.com.error_log; root /var/www/www.somepage.com; index index.php index.htm index.html; location / { post_action @afterdownload; } location @afterdownload { proxy_pass http://www.somepage.com/test/test.php?FileName=$request&ClientIP=$remote_addr&body_bytes_sent=$body_bytes_sent&status=$request_completion; internal; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /var/www/www.somepage.com$fastcgi_script_name; include fastcgi_params; } } 

和/test/test.php插入到MySQL的值:

 <?php require_once('../database.php'); mysqli_query($con, "INSERT INTO downloading (info) VALUES ('".mysqli_real_escape_string($con, serialize($_GET))."')"); ?> 

编辑:看起来像使用IP地址,而不是DNS帮助我在access_log中看到它

 [01/Sep/2013:12:47:01 +0200] "GET /test/test.php?FileName=GET /file.bin HTTP/1.1&ClientIP=89.176.81.33&body_bytes_sent=14161738&status= HTTP/1.0" 400 166 "-" "-" 

但仍然没有被存储在数据库中,而手动导航浏览器到/test/test.php?some=value存储在数据库中…

编辑:这是我现在在错误日志中获取:

 2013/09/02 11:27:23 [error] 9963#0: *658 upstream sent no valid HTTP/1.0 header while reading response header from upstream, client: 89.176.81.33, server: www.server.com, request: "GET /file.bin HTTP/1.1", upstream: "http://94.142.233.120:80/test/test.php?FileName=GET /file.bin HTTP/1.1&ClientIP=89.176.81.33&body_bytes_sent=89244088&status=OK", host: "www.server.com" 

你的要求有些虚伪。 看你的状态码:400。

检查你的$ request – variables(一切在“/test.php?FileName=”后面)

你可能想用$ uri来代替