Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


limit_rate_after nginx
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.

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?

    Thanked by 2portspeed netomx
  • @ehab said:
    when will you pay?

    pay for what? i don't owe you

  • @jazz1611 said:

    @ehab said:
    when will you pay?

    pay for what? i don't owe you

    You’re asking random strangers to do free sysadmin work for you.

    Thanked by 2portspeed maverickp
  • jazz1611 said: pay for what? i don't owe 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.

  • stefemanstefeman Member
    edited November 2018

    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.

    Thanked by 1netomx
  • Try placing the limit_rate in your data {} section.

    Thanked by 1jazz1611
  • 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

    Thanked by 1jazz1611
  • AlyssaDAlyssaD Barred
    edited November 2018

    Fixed Config:

    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;
        #}
    }
    
    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;
    
        # Move your limits down here. 
    
        limit_rate_after 10m;
        limit_rate 1m;
    }
    

    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.

  • @AlyssaD said:
    I am currently 26 years old as of 2018. I have lived all my life in the great state of California.

    Sweet Jesus I feel old.

    Thanked by 2eol netomx
  • @CyberMonday said:

    @AlyssaD said:
    I am currently 26 years old as of 2018. I have lived all my life in the great state of California.

    Sweet Jesus I feel old.

    Same.

  • @AlyssaD said:

    @CyberMonday said:

    @AlyssaD said:
    I am currently 26 years old as of 2018. I have lived all my life in the great state of California.

    Sweet Jesus I feel old.

    Same.

    Just wait for the weight of CA to bare down on you..

  • jazz1611jazz1611 Member
    edited November 2018

    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)

    Thanked by 1ehab
  • I'll be damned. Thank you.

    Thanked by 2netomx marrco
  • And they live happily ever after ... :)

    Thanked by 4Janevski ehab eol netomx
  • The End (is nigh).

    Thanked by 1netomx
  • @jazz1611 i am so proud of you.

    Thanked by 1netomx
  • How rarely does this LET happy ending happen?

Sign In or Register to comment.