czwartek, 23 maja 2013

nginx - secure download


http://wiki.nginx.org/HttpSecureLinkModule
location ~ ^/download/([a-zA-Z0-9_-]+)/([0-9]+)/(.*)$ {
                set $x_uri_hash $1;
                set $x_uri_expires $2;
                set $x_uri_file $3;
                secure_link $x_uri_hash,$x_uri_expires;
                secure_link_md5 SECRETTOKEN$x_uri_file$x_uri_expires;
                if ($secure_link = "") {
                       rewrite ^ /error/access_denied.html last;
                }
                if ($secure_link = "0") {
                       rewrite ^ /error/access_expired.html last;
                }
                rewrite ^ /files/$x_uri_file last
}
location /error/ {
            root /storage/download;
            internal;
 }
location /files/ {
            root /storage/download;
            set $limit_rate  512k;
            internal;
}

Brak komentarzy: