Saswat Padhi Saswat Padhi - 1 year ago 284
Bash Question

nginx - How to run a shell script on every request?

I want to run a shell script every time my nginx server receives any HTTP request. Any simple ways to do this?

Answer Source

You can execute 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 'os.execute("/bin/")';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download