From de1c3e0035dd46f996cc1ffeeb659073be288583 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Mon, 8 Jun 2020 10:02:43 +0200 Subject: [PATCH] fix api calls that define their own siapath --- setup-scripts/skynet-nginx.conf | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/setup-scripts/skynet-nginx.conf b/setup-scripts/skynet-nginx.conf index 16efe90c..9a02cb50 100644 --- a/setup-scripts/skynet-nginx.conf +++ b/setup-scripts/skynet-nginx.conf @@ -59,6 +59,8 @@ server { limit_conn uploads_by_ip 10; # ddos protection: max 10 uploads at a time client_max_body_size 1000M; # make sure to limit the size of upload to a sane value proxy_read_timeout 600; + proxy_request_buffering off; # stream uploaded files through the proxy as it comes in + proxy_set_header Expect $http_expect; # Extract 3 sets of 2 characters from $request_id and assign to $dir1, $dir2, $dir3 # respectfully. The rest of the $request_id is going to be assigned to $dir4. @@ -84,7 +86,38 @@ server { # you do not want to run your portal in the double siad setup. proxy_pass http://127.0.0.1:9970/skynet/skyfile/$dir1/$dir2/$dir3/$dir4$is_args$args; + add_header Access-Control-Allow-Origin *; + proxy_hide_header Access-Control-Allow-Origin; + # make sure to override user agent header - siad requirement + proxy_set_header User-Agent: Sia-Agent; + # replace BASE64_AUTHENTICATION with base64 encoded : + # for sia user is empty so it's just : + # to generate the passcode use https://www.base64encode.org or any other base64 encoder + proxy_set_header Authorization "Basic BASE64_AUTHENTICATION"; + } + + location ~ "/skynet/skyfile/(.*)" { + limit_conn uploads_by_ip 10; # ddos protection: max 10 uploads at a time + client_max_body_size 1000M; # make sure to limit the size of upload to a sane value + proxy_read_timeout 600; + proxy_request_buffering off; # stream uploaded files through the proxy as it comes in proxy_set_header Expect $http_expect; + + # we need to explicitly use set directive here because $1 will contain the siapath with + # decoded whitespaces and set will re-encode it for us before passing it to proxy_pass + set $siapath $1; + + # proxy this call to siad endpoint (make sure the ip is correct) + # + # note that we point uploads to port '9970', do this when you want to + # run in a configuration where you have two siad instances, one for + # downloads and one for uploads. This drastically improves the up - and + # download speed of your portal. When running your portal in this double + # siad setup, make sure only the download portal runs in 'portal mode'. + # The upload siad can be run in normal mode. Set the port to '9980' if + # you do not want to run your portal in the double siad setup. + proxy_pass http://127.0.0.1:9970/skynet/skyfile/$siapath$is_args$args; + add_header Access-Control-Allow-Origin *; proxy_hide_header Access-Control-Allow-Origin; # make sure to override user agent header - siad requirement