diff --git a/docker/nginx/conf.d/client.conf b/docker/nginx/conf.d/client.conf index 30887570..48d5037e 100644 --- a/docker/nginx/conf.d/client.conf +++ b/docker/nginx/conf.d/client.conf @@ -330,14 +330,13 @@ server { proxy_request_buffering off; # stream uploaded files through the proxy as it comes in proxy_set_header Expect $http_expect; + # rewrite proxy request to use correct host uri from env variable (required to return correct location header) + set_by_lua $SKYNET_SERVER_API 'return os.getenv("SKYNET_SERVER_API")'; + proxy_rewrite https://siad $SKYNET_SERVER_API; + # proxy /skynet/tus requests to siad endpoint with all arguments proxy_pass http://siad; - # rewrite tus headers to use correct uri from env variable - set_by_lua $SKYNET_SERVER_API 'return os.getenv("SKYNET_SERVER_API")'; - # proxy_redirect https://siad $SKYNET_SERVER_API; - proxy_set_header Host $SKYNET_SERVER_API; - # extract skylink from base64 encoded upload metadata and assign to a proper header header_filter_by_lua_block { if ngx.header["Upload-Metadata"] then diff --git a/docker/nginx/conf.d/include/cors b/docker/nginx/conf.d/include/cors index 1f7e4411..5245c33f 100644 --- a/docker/nginx/conf.d/include/cors +++ b/docker/nginx/conf.d/include/cors @@ -13,4 +13,4 @@ more_set_headers 'Access-Control-Allow-Origin: $http_origin'; more_set_headers 'Access-Control-Allow-Credentials: true'; more_set_headers 'Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, PUT, PATCH, DELETE'; more_set_headers 'Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,X-HTTP-Method-Override,upload-offset,upload-metadata,upload-length,tus-version,tus-resumable,tus-extension,tus-max-size,location'; -more_set_headers 'Access-Control-Expose-Headers: Content-Length,Content-Range,Skynet-File-Metadata,Skynet-Skylink,Skynet-Portal-Api,upload-offset,upload-metadata,upload-length,tus-version,tus-resumable,tus-extension,tus-max-size,location'; +more_set_headers 'Access-Control-Expose-Headers: Content-Length,Content-Range,Skynet-File-Metadata,Skynet-Skylink,Skynet-Portal-Api,Skynet-Server-Api,upload-offset,upload-metadata,upload-length,tus-version,tus-resumable,tus-extension,tus-max-size,location'; diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf index 75f807f9..41c15010 100644 --- a/docker/nginx/nginx.conf +++ b/docker/nginx/nginx.conf @@ -66,8 +66,11 @@ http { #gzip on; - # include skynet-portal-api header on every request - header_filter_by_lua 'ngx.header["Skynet-Portal-Api"] = os.getenv("SKYNET_PORTAL_API")'; + # include skynet-portal-api and skynet-server-api header on every request + header_filter_by_lua_block { + ngx.header["Skynet-Portal-Api"] = os.getenv("SKYNET_PORTAL_API") + ngx.header["Skynet-Server-Api"] = os.getenv("SKYNET_SERVER_API") + } include /etc/nginx/conf.d/*.conf; include /etc/nginx/conf.extra.d/*.conf;