[why] Use curl to upload files, cannot add symbolic links.
[how] nginx adds a symbolic link locally after receiving the file.
Signed-off-by: cuiyili 2268260388@qq.com --- container/result-webdav/nginx.conf | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/container/result-webdav/nginx.conf b/container/result-webdav/nginx.conf index 5ef3647..c880522 100644 --- a/container/result-webdav/nginx.conf +++ b/container/result-webdav/nginx.conf @@ -13,8 +13,10 @@ http { server_name "result-webdav"; server_tokens off; client_max_body_size 100m; + access_log /tmp/access.log; + error_log /tmp/error.log;
- location / { + location /result { allow all; root /srv/;
@@ -39,6 +41,32 @@ http { io.close(f) } } + location /initrd { + allow all; + root /srv/; + autoindex on; + create_full_put_path on; + dav_methods PUT MKCOL; + dav_access user:rw group:rw all:rw; + + access_by_lua_block { + uri = ngx.var.request_uri + + path = string.match(uri,"%g*/") + upload_file = string.match(uri, ".+/([^/]*%.%w+)$") + second_dir = string.match(uri, "/.+/(.*)/.+") + + if (second_dir == "pkg") + then + link_name = "latest.cgz" + else + link_name = string.match(upload_file, "(.*)_%d+%.cgz")..".cgz" + end + + root_patch = "/srv/"..path + io.popen("cd "..root_patch.."&& ln -sf "..upload_file.." "..link_name) + } + }
} }