浏览 674
当查看到本地文件不存在时,NGINX plus中是否能执行shell命令?我们想当出现不存在的文件时,执行脚本主动同步,我们是有另外的job在定时同步的,不过仍然是会有时间差,就是在这个时间中访问不存在的文件时,执行主动同步,然后返回用户,而不是返回404
按点赞数排序
按时间排序
不应该这么来弄,应该是结合lua/njs来做,通过njs/lua来判断文件是否存在
error_log stderr notice;
daemon off;
events { }
http {
include /usr/local/openresty/nginx/conf/mime.types;
server {
listen 80;
location @image_server {
content_by_lua_file "file_judge.lua";
}
location ~ ^/images/(?<sig>[^/]+)/(?<size>[^/]+)/(?<path>.*\.(?<ext>[a-z_]*))$ {
root cache;
set_md5 $digest "$size/$path";
try_files /$digest.$ext @image_server;
}
}
}
-- make sure the file exists
local file = io.open(source_fname)
if not file then
return_not_found()
end
file:close()
lua里面去判断文件存不存在
0
回答于2021-08-13 10:32