I want to run a shell script every time my nginx server receives any HTTP request. Any simple ways to do this?
相关问题
- How to get the return code of a shell script in lu
- Invoking Mirth Connect CLI with Powershell script
- Emacs shell: save commit message
- “command not found” errors in expect script execut
- Python script using subprocess and xclip hangs if
I found the following information online at this address: https://www.ruby-forum.com/topic/2960191
This does expect that you have fcgiwrap installed on the machine. It is really as simple as:
Example script (Must be executable)
Also using this as an include file, not restricted to only shell scripts.
I found it extremely helpful for what I am working on, I hope it help you out with your RaspberryPI project.
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.
I have tested the http request using curl and file gets download in
/tmp
directory of respective instance:OutPut:
Content of nginx.conf file: