且构网

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

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

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

您可以通过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")
  } 
}