Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to determine whether file was downloaded successfully or cancelled, following this article

I did everything the same, but I am trying to proxy_pass on the same server, not to the different one (like in this example is proxying from nginx to apache), is it even possible?

Looking into access log it acts like it is not giving me any response, i am trying to download a 100mb file at /file.bin, thanks for every suggestion!

Nginx config

server {
            listen 80;

            access_log /var/log/nginx/;
            error_log /var/log/nginx/;

            root /var/www/;
            index index.php index.htm index.html;

            location / {
              post_action @afterdownload;

            location @afterdownload {

            location ~ \.php$ {
              fastcgi_param  SCRIPT_FILENAME /var/www/$fastcgi_script_name;
              include fastcgi_params;


and /test/test.php to insert values into mysql:


mysqli_query($con, "INSERT INTO downloading (info) VALUES ('".mysqli_real_escape_string($con, serialize($_GET))."')");


EDIT: looks like using IP address instead of DNS helped me to see it in the access_log

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

but still nothing is being stored in the database, while manually navigating browser to /test/test.php?some=value stores in database...

EDIT: this is what I am getting in error log now:

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:, server:, request: "GET /file.bin HTTP/1.1", upstream: " /file.bin HTTP/1.1&ClientIP=", host: ""
share|improve this question
up vote 2 down vote accepted

your request is somewhat bogus. see your status-code: 400.

check your $request - variable (Everything behind "/test.php?FileName=")

you might want to use $uri instead

share|improve this answer
Thanks!!!! I also looked at this once but had no idea that it could not work because of one variable... now it works! – Wiggler Jtag Sep 3 '13 at 9:10
know your docs hahaha – that guy from over there Sep 3 '13 at 18:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.