| 8 | == What is SCGI? == |
| 9 | |
| 10 | SCGI stands for "Simple Common Gateway Interface". SCGI is a very lightweight and easy to parse protocol that allows any web server with SCGI support to pass requests to a separate program / application server. |
| 11 | |
| 12 | Various web servers such as Apache, lighttpd and nginx have support for SCGI which allows you to have HTTP requests to the web server sent out to a program (which is often called the application server) when then returns a response, ultimately delivered to the web browser. |
| 13 | |
| 14 | The communication is done via a socket and follows a particular protocol. Your program then sends an HTTP response back with headers and content (often <html> ... </html>, CSS, images, etc.). |
| 15 | |
| 16 | Here is a cheap diagram: |
| 17 | |
| 18 | [web browser] <--http--> [web server] <--scgi--> [app server/cobra] |
| 19 | |
| 20 | With the cobra-scgi library, you can easily set up such a program/appserver in Cobra. You write a Cobra method that takes the HTTP request and returns the response as a string. Inside that method, you can do whatever you like. |
| 21 | |
| 22 | So you can generate dynamic content from Cobra behind Apache and other web servers. |
| 23 | |
| 24 | == Sample == |
| 25 | |
| 26 | Here are [[sample key value pairs]] of what an SCGI-enable web server passes to the app server. |
| 27 | |
| 28 | There is a sample in the repository/workspace that shows how to use the library. |
| 29 | |
| 30 | == Configuration == |
| 31 | |
| 32 | Here are general steps. Further below under "Web Servers" you may find more detailed instructions. |
| 33 | |
| 34 | # Install mod_scgi for your web server if it doesn't have built-in support or does not already have the module. |
| 35 | # Configure your web server to point a path (such as /scgi or /) to a SCGI server on a port such as 4000 or 8000. |
| 36 | # Start your SCGI server. You can use the sample program that comes with cobra-scgi to start with. |
| 37 | # Visit the web server via your browser. |
| 38 | |
| 39 | What your browser displays should confirm that the web server passed the request to the app server which returned a response. |
| 40 | |
| 41 | == Web Servers == |
| 42 | |
| 43 | * [http://lighttpd.net Lighttpd] |
| 44 | * [http://httpd.apache.org Apache] |
| 45 | * [http://nginx.org Nginx], [http://wiki.nginx.org/NginxNgxSCGIModule SCGI Module] |
| 46 | * [http://www.cherokee-project.com/ Cherokee] |
| 47 | |
| 48 | == References == |
| 49 | |
| 50 | http://python.ca/scgi/protocol.txt |
| 51 | |
| 52 | http://en.wikipedia.org/wiki/Simple_Common_Gateway_Interface |
| 53 | |