This can be done with Lua but each disk access is a blocking call to nginx, your design should include caching of such calls (access disk once every 100 calls or after 60 seconds). Posted at Nginx Forum: https://forum.nginx.org/read.php?2,280529,280533#msg-280533