теперь и на хабре

  собираю карму, выдаю чужие идеи за свои.

  Чтобы не потерять:

http {
  limit_zone regular $zonekey 10m;
  limit_zone premium $zonekey 10m;
  server {
    root /www/oursiteishere;
    location / { try_files $uri @files; }
    location ~ \.php$ { try_files $uri @files; fastcgi_stuff_here; }
    location @files { rewrite ^(.*)$ /index.php?$1 last; }
    location /storage/ { root /storages/; internal; }
    # Location for regular users
    location ~ /download/.+/(.+)/0/.+/.*/(.+)$ {
    set $fname $2;
    set $username $1;
    set $zonekey "$binary_remote_addr $username";
    limit_conn regular 1;
    limit_rate '100k';
    secure_link_secret megasecret;
    secure_link_ttl on;
    if ($secure_link = "") { return 403; }
    add_header Content-Disposition "attachment; filename*=UTF-8''$fname";
    rewrite ^/download/([a-f0-9]+)/([\.~0-9a-zA-Z_]+)/([01])/([0-9]+)/(.+)/.+$ /storage/$4/$5 break;
  }
  # Location for premium users
  # Location for upload using upload module
}

Tags:

Leave a Reply