From ece202556199b76bf0684518986f64f5c352ced6 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Wed, 2 Jun 2021 17:56:35 +0200 Subject: [PATCH] /skynet/pin endpoint --- docker/nginx/conf.d/client.conf | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docker/nginx/conf.d/client.conf b/docker/nginx/conf.d/client.conf index 632a0c13..6d79c497 100644 --- a/docker/nginx/conf.d/client.conf +++ b/docker/nginx/conf.d/client.conf @@ -402,6 +402,25 @@ server { proxy_redirect https://siad/ https://$domain.$tld/; } + location /skynet/pin { + include /etc/nginx/conf.d/include/cors; + + # Extract 2 sets of 2 characters from $request_id and assign to $dir1, $dir2 + # respectfully. The rest of the $request_id is going to be assigned to $dir3. + # We use those variables to automatically generate a unique path for the uploaded file. + # This ensures that not all uploaded files end up in the same directory, which is something + # that causes performance issues in the renter. + # Example path result: /af/24/9bc5ec894920ccc45634dc9a8065 + if ($request_id ~* "(\w{2})(\w{2})(\w+)") { + set $dir1 $1; + set $dir2 $2; + set $dir3 $3; + } + + proxy_set_header User-Agent: Sia-Agent; + proxy_pass http://siad$uri?siapath=$dir/$dir2/$dir3&$args; + } + location /skynet/metadata { include /etc/nginx/conf.d/include/cors;