Welcome! Log In Create A New Profile

Advanced

X-Accel-Limit-Rate not working

Posted by SG 
SG
X-Accel-Limit-Rate not working
April 17, 2012 04:16AM
Is X-Accel-Limit-Rate supposed to work with "aio sendfile" on FreeBSD 9.0? It is not working for me.

It used to work earlier, but I noticed today that it no longer works. The only significant change I can remember making is in the http part of nginx.conf to turn on aio sendfile and give it a large read_ahead.

Relevant part of the nginx.conf file:

http {
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
aio sendfile;
read_ahead 32m;
access_log off;
fastcgi_read_timeout 200;
send_timeout 30;
keepalive_timeout 0;
server {
listen 80;
listen 7001;
location /files/ {
internal;
root /home/username;
post_action @done;
}
location @done {
internal;
rewrite ^ /donedownload.php?uri=$request_uri&sent=$body_bytes_sent;
}
}
}


then from my php app

header('Content-Encoding:');
header('Content-Type:');
header('X-Powered-By:');
header('Accept-Ranges: none');
header("X-Accel-Limit-Rate: $speedlimit");
header("Content-disposition: attachment; $userfilename");
header("X-Accel-redirect:/files/$filename");
SG
Re: X-Accel-Limit-Rate not working
April 27, 2012 04:21AM
I solved the problem. It has nothing to do with nginx.conf settings or freeBSD.

My php script was setting the limit after a calculation and the result of the calculation was a float. nginx is not able to process anything except an int for the X-Accel-Limit-Rate and so it was probably taking the value as zero which means unlimited.

A simple $speedlimit = intval($speedlimit) solved the problem.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 158
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