New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
limit_rate_after nginx
hello,
i have 2 server nginx storage mp4 video. i have set "limit_rate 1m" and "limit_rate_after 10m" on location but only limit_rate is work. i have search and know "limit_rate_after" will transfer first 10MB of video is fast then limit to 1MB/s. but when i test loading video, it just transfer 1MB/s when begin start video (not 10MB fast transfer first). there is my vhost configure:
location /video/ {
rewrite /video/([a-zA-Z0-9_\-]*)/([0-9]*)/(.*)\.mp4$ /data/$3.mp4?st=$1&e=$2;
valid_referers server_names domainABC.com;
if ($invalid_referer) {
return 403;
}
#if ($http_referer = "") {
# return 403;
#}
limit_rate_after 10m;
limit_rate 1m;
}
location /data/ {
internal;
secure_link $arg_st,$arg_e;
#secure_link_md5 abc$arg_e$uri$remote_addr;
secure_link_md5 abc$arg_e$uri;
if ($secure_link = "") { return 403; }
if ($secure_link = "0") { return 403; }
root /home;
mp4;
mp4_buffer_size 1m;
mp4_max_buffer_size 5m;
#mp4_limit_rate on;
#mp4_limit_rate_after 30s;
expires 7d;
#add_header Pragma public;
add_header Cache-Control public;
}
what issues i'm facing? sorry my for bad english. thank you.
Comments
when will you pay?
pay for what? i don't owe you
You’re asking random strangers to do free sysadmin work for you.
I'll use this reply when the mechanic is working on my car and I ask him for help without him putting a tool in his hand but just asking for advice and his opinion. I don't really owe him anything either.
You didin't even ask "Please", simply presented the problem for us to solve as if it was a matter of fact for someone to answer it for you for free.
Of course you'll get trolled.
Try placing the limit_rate in your data {} section.
not sure how "rewrite" works, but If your code would work with "alias".
Rewrite most likely works as a redirect and takes the directives of the destination, try doing what AlyssaD said, place the limit_rate and limit_rate_after in the data location
Fixed Config:
Now why is this happening...
The nginx rewrite is a "HTML Redirect". What this means is you are taking yoursite.com/video and telling it via a 301, or 302 code to go to yourside.com/data....
This means anyone can just go straight to yourside/data.... None the less, because of this it is no longer in the scope of /video/ and the limit_rates are no longer plausible. As such they don't get applied to the data directive where the information is coming from.
More info on redirects:
https://www.digitalocean.com/community/tutorials/how-to-create-temporary-and-permanent-redirects-with-nginx
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html
Since I have done this for you, you can easily give a donation for my time.
Also, just realize your invalid referer is useless.... because any site that will contact your webserver for the media will go straight to /data/ and pass your tests. Further, If I am not mistaken it will redirect the request to data before checking against your if statements making it already useless.
Sweet Jesus I feel old.
Same.
Just wait for the weight of CA to bare down on you..
thank you guys, the fixed config is working now. god bless for @AlyssaD
which the referer is work if playing video on domainABC.com (without will not work)
I'll be damned. Thank you.
And they live happily ever after ...
The End (is nigh).
@jazz1611 i am so proud of you.
How rarely does this LET happy ending happen?