Signed-off-by: cuiyili 2268260388@qq.com --- container/upload-libvirt-xml/nginx.conf | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 container/upload-libvirt-xml/nginx.conf
diff --git a/container/upload-libvirt-xml/nginx.conf b/container/upload-libvirt-xml/nginx.conf new file mode 100644 index 0000000..aef8fb8 --- /dev/null +++ b/container/upload-libvirt-xml/nginx.conf @@ -0,0 +1,43 @@ +# For more information on configuration, see: +# * Official English Documentation: http://nginx.org/en/docs/ + +user lkp; +worker_processes auto; +pid /run/nginx.pid; + +events {} + +http { + server { + listen 3081; + server_name "upload-libvirt-xml"; + server_tokens off; + client_max_body_size 50m; + access_log /tmp/access.log; + error_log /tmp/error.log; + + location / { + allow all; + root /srv/cci/libvirt-xml/; + + autoindex on; + create_full_put_path on; + dav_methods PUT MKCOL; + dav_access user:rw group:rw all:rw; + content_by_lua_block { + ngx.req.read_body() + local filename = string.gsub(ngx.var.request_uri, "/", "") + if string.match(filename, "([^/]+).xml$") then + add_path = string.match(filename, "([^/]+).xml$") + local data = ngx.req.get_body_data() + local file = io.open("/srv/cci/libvirt-xml/"..filename, "w") + file:write(data) + file:close() + file_md5 = io.popen("cd /srv/cci/libvirt-xml/ && file_md5=$(md5sum "..filename.." | awk '{print $1}') && mkdir -p "..add_path.." && mv "..filename.." "..add_path.."/${file_md5}.xml && echo ${file_md5}"):read() + ngx.say(add_path.."/"..tostring(file_md5)..".xml") + end + } + } + + } +}
local filename = string.gsub(ngx.var.request_uri, "/", "")
if string.match(filename, "([^/]+).xml$") then
add_path = string.match(filename, "([^/]+).xml$")
local data = ngx.req.get_body_data()
local file = io.open("/srv/cci/libvirt-xml/"..filename, "w")
file:write(data)
file:close()
file_md5 = io.popen("cd /srv/cci/libvirt-xml/ && file_md5=$(md5sum "..filename.." | awk '{print $1}') && mkdir -p "..add_path.." && mv "..filename.." "..add_path.."/${file_md5}.xml && echo ${file_md5}"):read()
too long line, better split it
Thanks, Luan Shengde
ngx.say(add_path.."/"..tostring(file_md5)..".xml")
end
}
- }
- }
+}
2.23.0
On Tue, Jan 26, 2021 at 10:19:31AM +0800, Cui Yili wrote:
Signed-off-by: cuiyili 2268260388@qq.com
container/upload-libvirt-xml/nginx.conf | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 container/upload-libvirt-xml/nginx.conf
diff --git a/container/upload-libvirt-xml/nginx.conf b/container/upload-libvirt-xml/nginx.conf new file mode 100644 index 0000000..aef8fb8 --- /dev/null +++ b/container/upload-libvirt-xml/nginx.conf @@ -0,0 +1,43 @@ +# For more information on configuration, see: +# * Official English Documentation: http://nginx.org/en/docs/
+user lkp; +worker_processes auto; +pid /run/nginx.pid;
+events {}
+http {
- server {
- listen 3081;
- server_name "upload-libvirt-xml";
- server_tokens off;
- client_max_body_size 50m;
- access_log /tmp/access.log;
- error_log /tmp/error.log;
- location / {
allow all;
root /srv/cci/libvirt-xml/;
autoindex on;
create_full_put_path on;
dav_methods PUT MKCOL;
dav_access user:rw group:rw all:rw;
content_by_lua_block {
ngx.req.read_body()
local filename = string.gsub(ngx.var.request_uri, "/", "")
if string.match(filename, "([^/]+).xml$") then
add_path = string.match(filename, "([^/]+).xml$")
local data = ngx.req.get_body_data()
local file = io.open("/srv/cci/libvirt-xml/"..filename, "w")
file:write(data)
file:close()
file_md5 = io.popen("cd /srv/cci/libvirt-xml/ && file_md5=$(md5sum "..filename.." | awk '{print $1}') && mkdir -p "..add_path.." && mv "..filename.." "..add_path.."/${file_md5}.xml && echo ${file_md5}"):read()
ngx.say(add_path.."/"..tostring(file_md5)..".xml")
ngx.say => ngx.print
Thanks, Xueliang
end
}
- }
- }
+}
2.23.0