Nginx post_action, Proxy_pass, 트랙 다운로드 파일

Nginx post_action, Proxy_pass, 트랙 다운로드 파일

이 문서에 따라 파일이 성공적으로 다운로드되었는지 또는 취소되었는지 확인하려고 합니다.http://www.tipstuff.org/2012/08/Nginx-post-action-to-trigger-successously-download-file.html

모든 작업을 동일하게 수행했지만 다른 서버가 아닌 동일한 서버에서 Proxy_pass를 시도하고 있습니다(이 예에서는 nginx에서 Apache로 프록싱하는 것처럼). 가능합니까?

액세스 로그를 살펴보면 아무런 응답도 없는 것처럼 작동합니다. /file.bin에서 100MB 파일을 다운로드하려고 합니다. 모든 제안에 감사드립니다!

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대신에

관련 정보