相关配置
location /files/permissive/ {
# internal;
client_max_body_size 4M;
dav_methods PUT DELETE MKCOL COPY MOVE;
create_full_put_path on;
dav_access group:rw all:r;
alias files/;
}
location = /test/files/permissive {
content_by_lua_block {
local json = require "cjson"
local res = ngx.location.capture("/files/permissive/test",
{method=ngx.HTTP_PUT,body=msg}
)
if res.status > 299 or res.status < 200 then
ngx.status = 500
ngx.say(json.encode(res) .. "\n")
return ngx.exit(500)
end
return ngx.exit(204)
}
}
结果:
>telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
PUT /files/permissive/test HTTP/1.0
Content-Length: 4
asdf
HTTP/1.1 201 Created
Server: openresty/1.13.6.2
Date: Sun, 04 Nov 2018 05:54:50 GMT
Content-Length: 0
Location: http://::1/files/permissive/test
Connection: close
Connection closed by foreign host.
>cat ./files/test
asdf⏎
>telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET /test/files/permissive HTTP/1.0
HTTP/1.1 500 Internal Server Error
Server: openresty/1.13.6.2
Date: Sun, 04 Nov 2018 05:56:19 GMT
Content-Type: text/plain
Content-Length: 118
Connection: close
{"body":"","header":{"Content-Type":"text\/plain"},"status":500,"truncated":true}
Connection closed by foreign host.
直接请求的时候没有问题,但是用`ngx.location.capture`请求就会发生不明原因500。
而error log和access log都没有关于这次PUT请求的记录。
那么这应该是什么问题呢