Answer the question
In order to leave comments, you need to log in
How to run bash script from nginx?
The task is as follows - for some request like example.org/do_the_job, you need to run a bash script on the frontend server.
All solutions found in Google come down to two methods:
1. install Lua and LuajIT on the server and use HttpLuaModule to run O_o
2. install another http server that can execute a CGI script that can run a bash command and pass the request to it o_O
On the frontend now only nginx is installed. The options to install apache/php/… are not very good.
upd. The solution was found - nginx was compiled with HttpPerlModule.
Added one more location according to the documentation - nginx.org/ru/docs/http/ngx_http_perl_module.html - and it all worked.
Answer the question
In order to leave comments, you need to log in
Well, I see two sane options:
First:
Jinx has a perl module, it is almost default. Directly in the config, you can make an exec of the desired script. --with-http_perl_module will help you.
The second option is generally delicious. Make our bashscript a daemon. And kick it with the CGI protocol.
The question is different - won't this be all a security hole?
In general, nginx, architecturally and for security reasons, does not support working with cgi. Therefore it is desirable to use FastCGI or http.
As mentioned above, do FastCGI.
If you use perl, please note that this script should not have blocking operations.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question