且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在每个请求上运行 shell 脚本?

更新时间:2022-12-04 08:29:46

您可以通过 nginx.conf 文件中的 Lua 代码执行 shell 脚本来实现此目的.您需要有 HttpLuaModule 才能执行此操作.

You can execute a shell script via Lua code from the nginx.conf file to achieve this. You need to have the HttpLuaModule to be able to do this.

这是执行此操作的示例.

Here's an example to do this.

location /my-website {
  content_by_lua_block {
    os.execute("/bin/myShellScript.sh")
  } 
}