Welcome! Log In Create A New Profile

Advanced

Problems with post_action

Posted by .paradox 
Problems with post_action
February 28, 2014 04:53PM
Hey Guys,

have a little problem and hope you can help.
On my site i want to offer some downloads.
Every download is using one same file but with differen id's like http://download.php?get=1
But i want to limit the traffic for the users so i have to log the sent_bytes.
But here is the first problem. i don't want to use logfiles like access.log i want to use post_action .
i had read some tutorials and configured nginx with the tutorials.

so far so good

i tested with the first howto ... with the second howto .... with the third howto
but the maximum i will get in the log is the following:

Array
(
[FileName] => /dl/download.php
[ClientIP] => ClientIP (f.e 1.234.567.89)
[body_bytes_sent] => 5 (But 5 is not the downloaded traffic, it is just the size of the download.php)
[status] => OK
)

Here is my nginx vhost config:

location ~ ^/dl/download.php
{
proxy_pass http://MYSERVERIP/count.php?FileName=$request_uri&ClientIP=$remote_addr&body_bytes_sent=$body_bytes_sent&status=$request_completion;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
post_action @afterdownload;
}

location @afterdownload
{
internal;
proxy_pass http://MYSERVERIP/count.php?FileName=$request_uri&ClientIP=$remote_addr&body_bytes_sent=$body_bytes_sent&status=$request_completion;
}

Can you explain me my fault please?

i tried with more proxy settings too:
(location download.php)
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X_Forwarded_Proto $scheme;
proxy_read_timeout 120;
proxy_connect_timeout 120;

and (location @ afterdownload:)
proxy_set_header RateBytes $body_bytes_sent;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X_Forwarded_Proto $scheme;
proxy_pass_request_body off;
proxy_pass_request_headers off;
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 150
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready