A
A
Aldekein2012-09-06 11:10:37
linux
Aldekein, 2012-09-06 11:10:37

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

5 answer(s)
W
WildWolf, 2012-09-06
@WildWolf

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?

K
kamiram, 2012-09-06
@kamiram

for example, make it a wrapper from cgi (on the same sh)

M
mr_idiot, 2012-09-06
@mr_idiot

In general, nginx, architecturally and for security reasons, does not support working with cgi. Therefore it is desirable to use FastCGI or http.

A
Andrey Burov, 2012-09-06
@BuriK666

As mentioned above, do FastCGI.
If you use perl, please note that this script should not have blocking operations.

V
VBart, 2012-09-06
@VBart

For these and many other purposes, uWSGI is ideal .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question