Can I serve CLI Applications using Nginx
Francis Daly
francis at daoine.org
Sat Jul 2 08:52:56 UTC 2022
On Thu, Jun 23, 2022 at 07:13:34PM +0600, Ahmad Ismail wrote:
Hi there,
> will it be a bad idea to extend nginx (ex. create a module) to serve
> my purpose instead of using inetd? Is it possible to make a module that
> will give the HTTP request to `Command1 | Command2 | CommandN`, then build
> a response from the output (by adding HTTP response message to it) and
> then send the response back to the client.
You can try that, but I suspect that you will find that you are
re-inventing CGI.
Your initial model of
Request | Web_Server | CLI_APP | ADD_UI | Web_Server > Response
is, I think, not quite right -- the "Web_Server" is not in the pipeline
twice; instead, the CLI_APP part is "off to the side".
Since you want the request to come in as http, you will probably be
happier if you keep your CLI_APP and ADD_UI pieces as they are in a
pipeline; but have a CGI wrapper that will call them and provide the
headers that any CGI-supporting web server will know how to handle.
As it happens -- nginx does not support CGI. So if you want to use nginx
in this model, you will want something like a FastCGI wrapper, or SCGI
wrapper, or something else that speaks a protocol that nginx does support.
For testing/design, you could use something like "date" as your dummy
CLI_APP; and then learn what you need to do to end up with the current
time showing in the browser.
I expect that you will either design your own interfaces that only work
in this case; or you will use pre-existing interfaces like CGI.
Good luck with it,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list