![Nginx post_action、proxy_pass、ダウンロードファイルの追跡](https://rvso.com/image/617239/Nginx%20post_action%E3%80%81proxy_pass%E3%80%81%E3%83%80%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%89%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AE%E8%BF%BD%E8%B7%A1.png)
この記事に従って、ファイルが正常にダウンロードされたかキャンセルされたかを確認しようとしていますhttp://www.tipstuff.org/2012/08/Nginx-post-action-to-trigger-successfully-download-file.html
すべて同じことをしましたが、別のサーバーではなく同じサーバーで proxy_pass しようとしています (この例では nginx から apache にプロキシしています)。これは可能ですか?
アクセス ログを見ると、何の応答もないように見えます。/file.bin にある 100 MB のファイルをダウンロードしようとしています。ご提案をありがとうございます。
Nginx の設定
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))."')");
?>
編集: DNSの代わりにIPアドレスを使用すると、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"
答え1
あなたのリクエストは多少不正確です。ステータス コード 400 を確認してください。
$request 変数を確認してください ("/test.php?FileName=" の後ろにあるすべて)
使用したいかもしれない$uriその代わり