Wednesday, April 17, 2013

How to use C as a scripting language in Nginx

Use either:

1. Instead of building a web server, you can consider to write a fastcgi
or scgi application.

2. You could look at the lua module. I hardly ever write C for nginx now. has some examples.

Also, I'm a big fan of using HTTP over things like fastcgi,scgi, etc.
Much easier to test, debug, etc. But that's just my opinion.

3. fcgiwrap

4. thttpd

5. mini-httpd

Nginx doesn't support CGI.

The best solution probably depends on what you're trying to achieve and your particular circumstances. As well as the solutions already suggested, one method I've used is to build the C program against libevent, effectively using libevent to build a mini webserver that is running all the time. nginx can then use that as an upstream proxy.

Start here:

libevent has all of the hard stuff done for you. You basically just need to use it's API to get hold of all the HTTP request information and to let it handle the response to the user.


No comments: