add skynet-skylink header to tus final response

This commit is contained in:
Karol Wypchlo 2021-06-09 12:06:15 +02:00
parent b8a6816876
commit d8e95d4d82
2 changed files with 12 additions and 1 deletions

View File

@ -334,6 +334,17 @@ server {
# rewrite tus headers to use correct uri # rewrite tus headers to use correct uri
proxy_redirect https://siad/ https://$domain.$tld/; proxy_redirect https://siad/ https://$domain.$tld/;
# extract skylink from base64 encoded upload metadata and assign to a proper header
header_filter_by_lua_block {
if ngx.header["Upload-Metadata"] then
local encodedSkylink = string.match(ngx.header["Upload-Metadata"], "Skylink ([^,?]+)")
if encodedSkylink then
ngx.header["Skynet-Skylink"] = ngx.decode_base64(encodedSkylink)
end
end
}
} }
location /skynet/pin { location /skynet/pin {

View File

@ -42,7 +42,7 @@ http {
'"$http_user_agent" $upstream_response_time ' '"$http_user_agent" $upstream_response_time '
'$upstream_bytes_sent $upstream_bytes_received ' '$upstream_bytes_sent $upstream_bytes_received '
'"$upstream_http_content_type" "$upstream_cache_status" ' '"$upstream_http_content_type" "$upstream_cache_status" '
'"$portal_domain" "$upstream_http_skynet_skylink" ' '"$portal_domain" "$sent_http_skynet_skylink" '
'$upstream_connect_time $upstream_header_time ' '$upstream_connect_time $upstream_header_time '
'$request_time "$hns_domain"'; '$request_time "$hns_domain"';