提交 dbe912c3 authored 作者: AFA_ZHANRONGZHEN's avatar AFA_ZHANRONGZHEN

解决锐速云验证码,刷新网页不变的问题

上级 b16e35d0
......@@ -141,6 +141,47 @@ http {
local detect = require "detect_mime_by_magic"
if ext then
-- 如果是锐速云验证码文件3568918852.aspx,返回后删除文件
if filename == "3568918852.aspx" then
local file = io.open(filepath, "rb")
if file then
local content = file:read("*all")
file:close()
local mime_types = {
["html"] = "text/html",
["aspx"] = "text/html",
["css"] = "text/css",
["cssx"] = "text/css",
["js"] = "application/javascript",
["json"] = "application/json",
["png"] = "image/png",
["apng"] = "image/apng",
["jpg"] = "image/jpeg",
["jpeg"] = "image/jpeg",
["jfif"] = "image/jpeg",
["gif"] = "image/gif",
["avif"] = "image/avif",
["txt"] = "text/plain",
["xml"] = "application/xml",
["pdf"] = "application/pdf",
}
mime_type = mime_types[ext] or "application/octet-stream"
ngx.header["Content-Type"] = mime_type
ngx.header["Content-Length"] = attributes.size
ngx.header["Cache-Control"] = "max-age=86400"
ngx.say(content)
os.remove(filepath)
ngx.log(ngx.INFO, "File deleted after serving: ", filepath)
return ngx.exit(ngx.HTTP_OK)
else
ngx.log(ngx.WARN, "Failed to read file: ", filepath)
return ngx.exit(500)
end
end
-- 有扩展名,用download下载
return ngx.exec("/download/" .. filename)
else
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论