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:-
- external request
- proxy pass to app for authorisation
- app returns X-Accel-Redirect if authorised then process download
- post_action to internal location
- 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/;
internal;
post_action /internal/finish_download;
}
location = /internal/finish_download {
internal;
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
location.
Posted at Nginx Forum: