我正在使用nginx上传文件。我已经安装了openresty模块以支持ngx lua。在上传文件时,我需要将upload_store变量更改为收到的POST标头中的路径。因此,我正在考虑使用lua更改nginx.conf中的upload_store指令值。我正在尝试从标头中获取Dst-Dir,如下所示:
location /umtest {
set $upload_store /mnt/share_marvel/uploaded_files;
rewrite_by_lua '
local header = ngx.req.raw_header()
ngx.say("type header",header)
dst_path_dir = #need to extract from header
ngx.var.upload_store = dst_path_dir
ngx.say("upload store path" ,ngx.var.upload_store)
';
从ngx.req.raw_header()收到的标头是
POST /umtest HTTP/1.1
Host: X.X.X.X:8888
Connection: keep-alive
Content-Length: 0
Cache-Control: no-cache
Dst-Dir : "/path/to/upload"
Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
如何提取Dst-Dir的值,以便可以将该值设置为upload_store?我对lua相当陌生。