body_bytes_sent always 0

steveh nginx-forum at
Thu Mar 24 01:12:11 MSK 2011

I'm trying to configure a post_action to submit details of downloads to
our app but when I do the body_bytes_sent is always 0 even after a
successful download.

The flow we have is:-
1. external request
2. proxy pass to app for authorisation
3. app returns X-Accel-Redirect if authorised then process download
4. post_action to internal location
5. internal location proxy passes to app to register download including
size which is used to determine if download completed

Its #5 where the issue appears as the download size passed via
X-Bytes-Sent is always 0

Here's the config for #4 and #5

location /files {
	alias /data/files/;
	post_action /internal/finish_download;

location = /internal/finish_download {
	proxy_set_header Host internal;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Original-Host $server_name;
	proxy_set_header X-Original-Uri $request_uri;
	proxy_set_header X-Bytes-Sent $body_bytes_sent;
	proxy_set_header X-Range $http_range;
	proxy_pass http://balancer/internal/finish_download;

Everything else seems to work fine its just X-Bytes-Sent is always 0,
I've checked in the access entry and size is set correctly so it seems
that $body_bytes_sent is lost by the time it gets into the post_action

Posted at Nginx Forum:,185270,185270#msg-185270

More information about the nginx mailing list