Is it possible to call a bash script from openresty? Also I would like to pass some variables from url parameters.
What I aiming is to run a script everyting a determinate URL is called from a external api and this script will add another location to nginx and will restart the server in order to apply the changes...
So I have the script ready and I have openresty installed on the box but whenever I try to do something like
content_by_lua "os.execute("/absolute/path/to/my/script.sh")";
I get the following error on my log:
2016/10/06 22:05:48 [error] 15913#0: *75 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 187.232.250.174, server: mybox, request: "GET /lua_content/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-mail-fpm.sock:", host: "mybox"
my nginx location:
location /nginx_var {
# MIME type determined by default_type:
default_type 'text/plain';
# try access /nginx_var?a=hello,world
content_by_lua_block {
os.execute("/absolute/path/to/my/script.sh")
}
}
inspiration from here: https://gist.github.com/aterreno/6208791
any help is greatly appreciated